我使用@GeneratedValue(strategy = GenerationType.AUTO)来生成我的实体上的ID.
我现在不知道它是如何工作的,但是在我的子表上,生成跟随父序列的ID值.
//parent table
@Entity
@Table (name = "parent")
public class Parent {
@Id
@GeneratedValue (strategy = GenerationType.AUTO)
@Column (name = "id")
private long id;
@OneToMany (cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
@JoinColumn (name = "parentId")
@ForeignKey (name = "FKparent")
private List<child> child;
}
//child table
@Entity
@Table (name = "child")
public class Child {
@Id
@GeneratedValue (strategy = GenerationType.AUTO)
@Column (name = "id")
private long id;
}
Run Code Online (Sandbox Code Playgroud)
父项上插入的ID值会更新序列.在child上插入ID值,更新序列.在下一个父项插入时,序列...使用由子插入更新的值...
这个Annotations,不是创建两个序列,只有一个.这是正确/预期的吗?
我只使用我的DAO服务插入我的实体 entityManager.persist(parent);
我不知道如何在java属性文件中转义'.我正在使用struts2和getText函数来填充i18n和文本标签.
例如,我使用:config.users.title = taula d'usuaris ---> config.users.title = taula d \'usuaris
但是在我的JSP中,我得到了:taula dusuaris.
我使用它来显示我的JSP上的文本:
<label for="title"><s:text name="config.users.title" />:</label>
Run Code Online (Sandbox Code Playgroud)
我有时也会使用:
<s:select id="categories" name="categories" headerKey=""
headerValue="%{getText('map.categories.all')}"
list="categories" listKey="id" listValue="name"/>
Run Code Online (Sandbox Code Playgroud)
错误是什么?
谢谢!
我在org.hibernate.MappingException: No Dialect mapping for JDBC type: 2002尝试执行JPA nativeQuery以获取几何字段类型时遇到问题。
我正在使用Oracle和org.hibernatespatial.oracle.OracleSpatial10gDialect。
几何字段映射为:
@Column(name="geometry")
@Type(type = "org.hibernatespatial.GeometryUserType")
private Geometry geometry;
// ...
List<Object> listFeatures = new LinkedList<Object>();
Query query = entityManager.createNativeQuery(
"SELECT "+ slots +" , geometry FROM edtem_features feature, edtem_dades dada WHERE" +
" feature."+ tematic.getIdGeomField() +" = dada."+ tematic.getIdDataField()+
" AND dada.capesid= "+ tematic.getCapa().getId() +
" AND feature.geometriesid= "+ tematic.getGeometria().getId());
listFeatures.addAll(query.getResultList());
Run Code Online (Sandbox Code Playgroud)
这是我在spring + struts2上的休眠配置
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property …Run Code Online (Sandbox Code Playgroud)