persistence

Oracle thin driver vs. OCI driver. Pros and Cons?

↘锁芯ラ 提交于 2020-01-12 12:03:15
问题 When you develop a Java application that talks to oracle DBs, there are 2 options right? One is oracle thin driver, and the other is OCI driver that requires its own installation (please correct if I'm misunderstanding). Now, what are the pros and cons? Obviously thin driver sounds much better in terms of installation, but is there anything that OCI can and the thin one can't? Develop environment is Tomcat6 + Spring 3.0 + JPA(Hibernate) + apache-DBCP 回答1: The choice of the driver depends

Oracle thin driver vs. OCI driver. Pros and Cons?

耗尽温柔 提交于 2020-01-12 12:03:06
问题 When you develop a Java application that talks to oracle DBs, there are 2 options right? One is oracle thin driver, and the other is OCI driver that requires its own installation (please correct if I'm misunderstanding). Now, what are the pros and cons? Obviously thin driver sounds much better in terms of installation, but is there anything that OCI can and the thin one can't? Develop environment is Tomcat6 + Spring 3.0 + JPA(Hibernate) + apache-DBCP 回答1: The choice of the driver depends

Persisting graph data (Java)

霸气de小男生 提交于 2020-01-12 02:30:09
问题 I have an application which utilizes graph (tree-like) custom structures. The structures are not real trees, but pretty much everything is connected together. The quantity of the data is also big (millions of nodes can exist). Tree-nodes can vary in type to make it more interesting (inheritance). I don't want to alter the data-structures to accommodate the persistence storage. I want to persist this data without too much extra work. I've goggled some options to solve this problem, but couldn

Change entity using Hibernate PreInsertEventListener

余生长醉 提交于 2020-01-11 05:10:31
问题 I am using Hibernate 4.1 trying to call a PreInsertEventListener to update the entity before inserting it into the database, based on the article here: http://anshuiitk.blogspot.ca/2010/11/hibernate-pre-database-opertaion-event.html public class PreInsertListener implements PreInsertEventListener { @Override public boolean onPreInsert(PreInsertEvent event) { Product product = (Product)event.getEntity(); String barcode = "B" + product.getProductId(); product.setBarcode(barcode); // Update the

Hibernate/JPA: Is it possible to retrieve heterogeneous entities in a single query?

坚强是说给别人听的谎言 提交于 2020-01-10 03:13:25
问题 I have 2 entities: EntityA and EntityB. They are unrelated, and I cannot put them in a Inheritance tree for some restrictions out of the scope of this question. But I need to get in the same JPQL or HQL query a mixed List containing all the instances of both entities. Is this possible with JPA or even Hibernate directly? I need somethign like this: FROM EntityA WHERE fieldA=1 UNION FROM EntityB WHERE fieldB="aa" Any hint? 回答1: Well, I finally figured it out. It is enought to make the entities

Hibernate/JPA: Is it possible to retrieve heterogeneous entities in a single query?

大兔子大兔子 提交于 2020-01-10 03:13:25
问题 I have 2 entities: EntityA and EntityB. They are unrelated, and I cannot put them in a Inheritance tree for some restrictions out of the scope of this question. But I need to get in the same JPQL or HQL query a mixed List containing all the instances of both entities. Is this possible with JPA or even Hibernate directly? I need somethign like this: FROM EntityA WHERE fieldA=1 UNION FROM EntityB WHERE fieldB="aa" Any hint? 回答1: Well, I finally figured it out. It is enought to make the entities

what is the right path to refer a jar file in jpa persistence.xml in a web app?

两盒软妹~` 提交于 2020-01-08 17:15:21
问题 persistence.xml looks like this: <persistence-unit name="testPU" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <non-jta-data-source>jdbc/test</non-jta-data-source> <jar-file>../../lib/app-services-1.0.jar</jar-file> <exclude-unlisted-classes>false</exclude-unlisted-classes> </persistence-unit> It is a web project, so the deployment unit is a war file. The jar file I tried to refer is in WEB-INF/lib/ folder , persistence.xml is in WEB-INF

what is the right path to refer a jar file in jpa persistence.xml in a web app?

折月煮酒 提交于 2020-01-08 17:15:11
问题 persistence.xml looks like this: <persistence-unit name="testPU" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <non-jta-data-source>jdbc/test</non-jta-data-source> <jar-file>../../lib/app-services-1.0.jar</jar-file> <exclude-unlisted-classes>false</exclude-unlisted-classes> </persistence-unit> It is a web project, so the deployment unit is a war file. The jar file I tried to refer is in WEB-INF/lib/ folder , persistence.xml is in WEB-INF

JPA - Using composite PK's and FK's and defining relationships

穿精又带淫゛_ 提交于 2020-01-07 04:58:07
问题 I got these 2 entities: @javax.persistence.Entity public class Book { @javax.persistence.EmbeddedId private BookPK id; private String title; @javax.persistence.ManyToOne(fetch = javax.persistence.FetchType.LAZY) @javax.persistence.JoinColumns({ @javax.persistence.JoinColumn(name = "LNGCOD", referencedColumnName = "LNGCOD"), @javax.persistence.JoinColumn(name = "LIBCOD", referencedColumnName = "LIBCOD") }) private Language language; } @javax.persistence.Entity public class Language { @javax

Entity Object Not Getting Persisted: New object was found through a relationship that was not marked

爱⌒轻易说出口 提交于 2020-01-06 19:56:00
问题 I am trying to persist the following entity: public class CommentEntity { @Id @ManyToOne(optional=false,cascade=CascadeType.REFRESH, targetEntity=UserEntity.class) @JoinColumn(name="USERID",referencedColumnName="USERID") private UserEntity userEntity; @ManyToOne(optional=false,cascade=CascadeType.REFRESH, targetEntity=PostEntity.class) @JoinColumn(name="POSTID",referencedColumnName="POSTID") private PostEntity postEntity; } But the error comes out: During synchronization a new object was