FAQ Database Discussion Community


Attempt to set column “system_user.id” to two different values

java,exception,jpa,openjpa
Caused by: org.apache.openjpa.persistence.InvalidStateException: Attempt to set column "system_user.id" to two different values: (class java.lang.Integer)"6", (class java.lang.Long)"3,651" This can occur when you fail to set both sides of a two-sided relation between objects, or when you map different fields to the same column, but you do not keep the values of...

Combine parameters and hardcoded clauses in Spring JPA @Query

spring,jpa,openjpa
I have a user repository in the application which works nicely for cases like this one: @Query(" FROM UserEntity ue WHERE ue.site.id = :site_id and ue.name = :username") User findByUsername(@Param("site_id") String siteId, @Param("username") String userName); There is now a new option in one of the user fields, which should prevent...

OpenJPA OneToMany and composite key in parent and child table

java,jpa,jpa-2.0,openjpa
I have tables with composited primary key. Server(key=ServerId) ServerId|Name 1 |server1 2 |server2 ParentObj(key=ServerId+Code) ServerId|Code |Title 1 |code1|value1 1 |code2|value2 2 |code1|Value2b ChildObj(key=ServerId+Code+Name) ServerId|Code |Name |Value 1 |code1|prop1|val1 1 |code1|prop2|val2 1 |code2|prop1|val1b 2 |code1|prop3|val3 This is Java beans I have. @Entity @Table(name="ParentObj") @Access(AccessType.FIELD) @IdClass(value=ParentObj.PK.class) @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) @XmlRootElement public class ParentObj {...

JPA cross unidirectional OneToOne

java,jpa,openjpa
I have two entity-classes A and B. For A there is only one instance of class B. Through a lifecicle of application I need to create new instnace of B for A. But for history log I need to store previous instance of B with links to an this A...

jpa namedquery with literals changed to prepared statement

jpa,prepared-statement,openjpa,named-query,sqlperformance
I have a jpa (openjpa-2.2.1) namedquery that has some hardcoded literals (ex: a.status <> 'X') - the problem is at runtime the generated query is actually a prepared statement (a.status <> ?) Is there a way to force JPA run the query as is? (i would like to keep it...

performance of executing openjpa query

java,performance,jpa,openjpa
I have a rest web app with cxf 3.0.1 framework and openjpa 2.3.0. The web.xml: <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>Mobile app rest services</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/cxf-servlet.xml</param-value>...

OpenJPA and stored procedures, Weblogic 12c

java,stored-procedures,jdbc,weblogic,openjpa
Kinda specific question, but this is what I'm struggling with. I used OpenJPA 1.2.3 on Weblogic 11g, calling stored procedures on a Sybase database. Used the com.sybase.jdbc2.jdbc.SybDriver. Recently we upgraded to the Weblogic 12c, and that configuration didn't work as well as hoped. When excecuting the application that performed the...

Using an @Embeddable entity in a JPA CriteriaQuery

java,jpa,criteria,openjpa,criteria-api
Let's say I have the following example entities - one is an @Embeddable, embedded inside another @Entity: @Embeddable public class ContactInfoEntity { @Column private String phone; @Column private String zipCode; } @Entity @Table(name = "EMPLOYEE") public class EmployeeEntity { @Id @Column(name = "EMPLOYEE_ID") private Long employeeId; @Embedded @AttributeOverrides({ @AttributeOverride(name =...