openjpa

JPA - multiple persistence units

半腔热情 提交于 2019-12-12 02:53:15
问题 I'm using JPA and I am connecting to multiple databases. Below is the persistence.xml - <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit name="myRead" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /> <property name="hibernate.show_sql" value="true" /> </properties> </persistence-unit> <persistence

OSGi using jpa persistence unit from another bundle?

女生的网名这么多〃 提交于 2019-12-12 02:08:18
问题 I use ServiceMix with Apache Felix and my Enterprise Application consist of several bundles. For example I have a bundle with my jpa entity classes and another bundle with business logic and dao-classes. Because of I use OpenJPA the entity-bundle project needs the persistenc.xml in META-INF folder for bytecode injection at compiletime, but this bundle provides the persistence unit by the Meta-Persistence header in the bundle manifest. Inside of the dao providing bundle I inject the entity

Foreign key as a part of composite primary key and ManyToOne relationship in OpenJPA

我的梦境 提交于 2019-12-11 23:38:39
问题 I want to create simple database with OpenJPA 2.3. TableA: - f_id PK - item PK - release PK - b_id PK - field1 - field2 TableB: - id PK - name - date Where b_id in TableA references to id in TableB (MANY TableA rows to ONE TableB row). b_id is a part of entire composite primary key. TableA class: @Entity @IdClass(TableA_PK.class) public class TableA implements Serializable { @Id private int fId; @Id private String item; @Id private String release; @Id @ManyToOne @PrimaryKeyJoinColumn(name="b

JPA OneToMany with Jointable, deleting a link deletes right-side object

血红的双手。 提交于 2019-12-11 19:27:35
问题 (OpenJPA2.x) I have Parent->(linktable)->Category relation. If I remove category from parent's category array it gets properly deleted from the linktable ( unlinked ). Adding a new category to an array gets inserted to the linktable. However problem is category target entity is also deleted from Category table. I have debugged jdbc queries and it's performed by OpenJPA library, db tables don't have a cascaded delete constraint. Parent(key=ServerId,Code) ServerId|Code |Name 1 |code1|name1 1

Entity class cannot be cast to java.lang.Number

社会主义新天地 提交于 2019-12-11 18:38:50
问题 This issue is a continuation of this problem: Foreign key as a part of composite primary key and ManyToOne relationship in OpenJPA OpenJPA is tring to cast my entity class ( TableB ) to type of its key ( long ). Why? Persisting of TableB object without any elements in field rows works fine. The problem begins when 'm adding elements to rows . TableA.class: package org.model; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence

How to access Map field in JPA via JPQL

假装没事ソ 提交于 2019-12-11 12:12:42
问题 for example, if there is an @ElementCollection file which is with a Map type, then if I try to get the map key or value field then how to process? Class Deal{ ..... private String name; private String department; private DealType type; @AttributeOverrides({ @AttributeOverride(name="value.in.available", column=@Column(name="in_avl")), @AttributeOverride(name="value.in.unavailable", column=@Column(name="in_unv")), @AttributeOverride(name="value.out.available", column=@Column(name="out_avl")),

How can I “move” an object from one table to another using OpenJPA?

喜夏-厌秋 提交于 2019-12-11 07:34:53
问题 I have two tables, that share the same definition. I commonly insert new objects into one of these tables, let's call it Table1. From time to time, I want to move one entry from Table1 to the other table (Table2). How can I achieve this using the OpenJPA Framework? The object is clearly bound to one table ... @Entity @Table(name="TRACKING") public class TrackingEntry { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Integer id; @Column(name="LASTNAME") private String lastName;

OpenJPA HSQLdb - how to handle IDs

为君一笑 提交于 2019-12-11 06:28:55
问题 I'm having trouble handling IDs of my databse tables using OpenJPA and HSQLdb. I created an Abstract class where I handle annotations and stuff to remap into the DB: // Property accessors @Id @Column(name = "IDTESTOBJEKT", unique = true, nullable = false) public Integer getIdtestobjekt() { return this.idtestobjekt; } public void setIdtestobjekt(Integer idtestobjekt) { this.idtestobjekt = idtestobjekt; } It's as a Facade used to create Testobjekts. Testobjekt test_obj = new Testobjekt(); test

The type “class *” has not been enhanced JPA exception

喜夏-厌秋 提交于 2019-12-11 04:54:12
问题 I am running WebSphere v8, and using JPA persistence in a Java EE 6 environment. When I attempt to run code that deals with a particular entity, I run into this exception: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: org.apache.openjpa.persistence.ArgumentException: The type "class au.com.combined.domain.changeroutine.ChangeRoutineConsumedPK

OpenJPA query fails second time (possibly because of byte array parameter)

吃可爱长大的小学妹 提交于 2019-12-11 04:07:46
问题 I have following OpenJPA query (over db2 database): Select number from Number number where number.uuid = :uuid Column uuid defined as VARCHAR FOR BIT DATA(16). In entity it represented as byte[] type field. The problem is that when I call method with that query first time(after WebSphere server is up) it works fine. Consequential calls result in error (I even enabled trace log see where the error is) 1st time:> query is running, everything's ok [11/25/15 13:27:03:803 IST] 0000001d Query 3