Jpa实体生成器将Integer类型分配给我的实体的id字段.我的数据库中相应的属性/列是serial(yep postgres
)类型.我还会将整数类型分配给我的实体id字段.但我已经看到Long getId()
在这个页面上的用法.我也在geomajas示例中看到了这种类型的分配.在使用方面有什么问题Integer
吗?我的意思是,是的,你必须小心id不低于0的整数,但同时你还必须确保你的Long Id不大于2,147,483,647.那么这里有什么关系?
编辑:我正在Long
和无符号整数之间产生混淆,所以我想我的想法是"无符号整数与Integer
java实体的id字段",这是无意义的,因为我的长整数和无符号整数之间的混淆消失了.我的错.感谢您的回答和评论.我想如果我会使用bigserial jpa实体生成器也会使用Long.
我知道这可能是重复的,具有讽刺意味的是,在我开始阅读这里和那里之前,我知道我知道它是什么(无需说出来但我仍然会说,请纠正我错在哪里):
它减轻程序员必须使用transaction.begin()和transaction.begin()
.如果你有一个调用两个DAO方法的方法,通常每个方法都包含commit()
并transaction.begin
包含实际操作并调用它们,那么它将导致两个事务(如果前面的dao方法也应该回滚,则可能存在回滚问题).但是,如果你用transaction.commit
你的方法,然后这些人DAO呼叫将被包裹在一个单一的@transactional
- begin()
周期.当然,如果你使用commit()
DAO,一定不要使用@Transactional
和begin()
方法我认为.
我的休息条件:
事件instanceof org.geomajas.gwt.client.widget.event.SearchEvent我尝试了其他变体,例如事件instanceof SearchEvent/with parantheses and with/out";"
错误:评估必须包含表达式或格式良好的语句块
解决方案: ?
顺便说一下,我正在使用jdk 1.6.25
鉴于这里的查询示例:http://www.hibernatespatial.org/tutorial-hs4.html
Query query = em.createQuery("select e from Event e where within(e.location, :filter) = true", Event.class);
query.setParameter("filter", filter);
Run Code Online (Sandbox Code Playgroud)
是否可以使用jpa 2标准api重写查询?(我不确定我应该如何处理该within(e.location, :filter)
部分.
如果我运行mvn archetype:生成它有效,但如果我尝试
mvn archetype:generate -DarchetypeGroupId org.codehaus.mojo -DarchetypeArtifactId gwt-maven-plugin -DarchetypeVersion=2.5.0
Run Code Online (Sandbox Code Playgroud)
该消息来自我上次使用反斜杠的尝试,但它与没有斜杠命令的消息相同
E:\mavenplay\a>mvn archetype:generate \ -DarchetypeGroupId org.codehaus.mojo \ -
DarchetypeArtifactId gwt-maven-plugin \ -DarchetypeVersion=2.5.0 -X
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 15:51:
28+0200)
Maven home: E:\apache-maven-3.0.5\bin\..
Java version: 1.6.0_25, vendor: Sun Microsystems Inc.
Java home: E:\Program Files\Java\jdk1.6.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from E:\apache-maven-3.0.5\bin\..\conf\settings.
xml
[DEBUG] Reading user settings from C:\Users\henkel\.m2\settings.xml
[DEBUG] Using …
Run Code Online (Sandbox Code Playgroud) 会发生什么:我的java编译器设置从我的自定义jdk重置为默认java se1.5
当它停止:每次我点击maven-更新项目(当然在eclipse中).
我认为它与更新项目设置复选框有关.但我无法在我的pom中找到负责配置我的eclipse项目的标签.任何提示?
BTW我不能只取消选中该框,因为pom可能有其他设置对我的项目至关重要
编辑:抱歉延迟,这是我的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!-- <parent> -->
<!-- <groupId>org.geomajas</groupId> -->
<!-- <artifactId>geomajas-parent</artifactId> -->
<!-- <version>1.0.9</version> -->
<!-- </parent> -->
<modelVersion>4.0.0</modelVersion>
<groupId>ne</groupId>
<artifactId>projl</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>TApp</name>
<description>Test</description>
<url>http://www.example.com/</url>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.geomajas</groupId>
<artifactId>geomajas-backend</artifactId>
<version>1.13.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.geomajas</groupId>
<artifactId>geomajas-face-puregwt</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.geomajas.plugin</groupId>
<artifactId>geomajas-plugin-geotools-all</artifactId>
<version>1.10.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.geomajas.plugin</groupId>
<artifactId>geomajas-plugin-rasterizing-all</artifactId>
<version>1.2.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.geomajas.plugin</groupId>
<artifactId>geomajas-widget-puregwt-core-all</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.geomajas</groupId>
<artifactId>geomajas-dep</artifactId>
<version>1.12.28</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> …
Run Code Online (Sandbox Code Playgroud) 如果我不粘贴 xmlns:tx="http://www.springframework.org/schema/tx"
那么没有问题.但是,如果我插入文本,我得到一个cvc-complex-type.2.4.c:匹配的通配符是严格的,但是没有找到元素'tx:annotation-driven'错误的声明.
<beans xmlns:tx="http://www.springframework.org/schema/tx" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<context:annotation-config />
<tx:annotation-driven />
<context:component-scan base-package="ne.projl.server" />
<bean name="security.securityInfo" class="org.geomajas.security.SecurityInfo">
<property name="loopAllServices" value="false" />
<property name="securityServices">
<list>
<bean class="org.geomajas.security.allowall.AllowAllSecurityService" />
</list>
</property>
</bean>
<bean name="puregwt-app" class="org.geomajas.configuration.client.ClientApplicationInfo">
<property name="maps">
<list>
<ref bean="mapOsm" />
<!-- <ref bean="mapWms" /> -->
<!-- <ref bean="mapLegend" /> -->
<!-- <ref bean="mapLayerVisibility" /> -->
<!-- <ref bean="mapCountries" /> -->
<!-- <ref bean="mapEmpty" /> -->
<!-- <ref bean="mapPrinting" /> -->
</list>
</property> …
Run Code Online (Sandbox Code Playgroud) 以下代码返回错误,但我不确定原因.需要更改什么才能进行编译?
switch (DAO.class) {
case BookDAO.class:
return bookDAO;
}
Run Code Online (Sandbox Code Playgroud) java ×5
eclipse ×2
jpa ×2
maven ×2
spring ×2
criteria-api ×1
debugging ×1
hibernate ×1
m2e ×1
maven-3 ×1
maven-plugin ×1
persistence ×1
spring-jdbc ×1
spring-mvc ×1
transactions ×1