eclipselink

Perform UPDATE without SELECT in eclipselink

心不动则不痛 提交于 2019-12-29 06:29:07
问题 Is is possible (without writing custom SQL) to have Eclipselink trust me as to whether to perform an update or insert on a merge, rather than perform a select, then an update or insert? If so, how? In my mind I'd like to use a transient flag and a custom if statement to determine whether the item is already in the database or not, and instruct eclipselink to perform the query required. I understand Hibernate provides this as update() and save() A few notable points: I have a large amount of

How to refresh updated entity data without restarting the server

╄→гoц情女王★ 提交于 2019-12-25 18:40:19
问题 I am using EclipseLink JPA as ORM and web logic 10.3 as an application server in my project. Everything working fine until i got a bug for data refresh. Here is the case one of my entity table row is updated to new value but my entity manager or JPA did not pick that value. For this we have lite rely re started the server. then it picked up the value. Here is my persistence.xml file and here is the way i am using entity manager in my class. <persistence-unit name="BasePersistenceUnit"

Adding entity doesn't refresh parent's collection

半世苍凉 提交于 2019-12-25 18:24:57
问题 the question and problem is pretty simple, though annoying and I am looking for a global solution, because it's application-wide problem for us. The code below is really not interesting but I post it for clarification! We use PostgreSQL database with JPA 2.0 and we generated all the facades and entities, of course we did some editing but not much really. The problem is that every entity contains a Collection of its children, which however (for us only?) is NOT updated after creation a

How to apply @OneToMany on super class getter method in multiple subclasses with different target entity

半城伤御伤魂 提交于 2019-12-25 14:40:25
问题 Stack I'm using JPA2.0 with Eclipselink 2.6.3 and Spring 4(JTA). Problem I'm trying to override the class A attribute with @OneToMany mapping in class B and class C (which is similar to class B ) so that I can change the target entity to class X and Z respectively while fetching results for class B. Class A has SINGLE_TABLE inheritance and class B & C are discriminator classes which is maintained by @classExtractor depending on some field value in class A. Class Z has TABLE_PER_CLASS

How to apply @OneToMany on super class getter method in multiple subclasses with different target entity

百般思念 提交于 2019-12-25 14:40:03
问题 Stack I'm using JPA2.0 with Eclipselink 2.6.3 and Spring 4(JTA). Problem I'm trying to override the class A attribute with @OneToMany mapping in class B and class C (which is similar to class B ) so that I can change the target entity to class X and Z respectively while fetching results for class B. Class A has SINGLE_TABLE inheritance and class B & C are discriminator classes which is maintained by @classExtractor depending on some field value in class A. Class Z has TABLE_PER_CLASS

Setting V$SESSION.program property on Glassfish JDBC Connection Pool

血红的双手。 提交于 2019-12-25 14:05:16
问题 my Java EE App is deployed on Glassfish 3.0.1, and uses a JDBC Connection Pool to Connect to an Oracle 9i database. I am using JPA to read/write data to the database, which is working fine. However, to get better reporting regarding the load this app is putting on the database, I want to set the V$SESSION.program column for use by oracle. From various google searches (eg. http://forums.oracle.com/forums/thread.jspa?messageID=3271623) it looks like I should just be able to add this as a

Setting V$SESSION.program property on Glassfish JDBC Connection Pool

笑着哭i 提交于 2019-12-25 14:04:24
问题 my Java EE App is deployed on Glassfish 3.0.1, and uses a JDBC Connection Pool to Connect to an Oracle 9i database. I am using JPA to read/write data to the database, which is working fine. However, to get better reporting regarding the load this app is putting on the database, I want to set the V$SESSION.program column for use by oracle. From various google searches (eg. http://forums.oracle.com/forums/thread.jspa?messageID=3271623) it looks like I should just be able to add this as a

Is JPA also lazy for primitive attribues?

时光毁灭记忆、已成空白 提交于 2019-12-25 09:27:20
问题 I'm trying to detect the N+1 problem in my code. Every example I've found of the issue always involves two entities, which doesn't really explains if that could also happen to single entities. The general example is: A car has many wheels. For each car I want to get every wheel. Select * from cars Select * from wheels where carId=? or List<Car> cars = getCarsFromDB(); for(Car car : cars){ List<Wheel> wheels = car.getWheels(); //Wheels are entities. } But what about non-entities?: List<Car>

Empty List (not Table) at ManyToMany-Relation

别等时光非礼了梦想. 提交于 2019-12-25 09:04:26
问题 i faced the same problem as empty tables when using many to many relations in jpa. Sadly this post was without solution. I have a class with a many-to-many relation in JPA/EclipseLink v2.6.3. Here the class ROLE: @Entity public class Role implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.MERGE) @JoinTable(name = "ROLE_COMPETENCE", joinColumns = @JoinColumn(name = "ROLE_ID",

JPA create, edit and delete entities from database

感情迁移 提交于 2019-12-25 07:39:58
问题 How should I manage the create, edit and delete operations with entites as simple as possible? For example: User: public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; private String name; ... // Item can't exist without user @OneToMany(cascade=CascadeType.ALL,mappedBy = "user",orphanRemoval=true) private Set<Item> items = new HashSet<Item>(); public Set<Item> getItems() { return items; } public void addItem(Item item) { items.add(item); } public void