openjpa

java.lang.UnsupportedOperationException in JPA transaction

I'm pretty sure that I'm not understanding something about JPA (I'm using OpenJPA) and it's causing this problem. I want to make a copy of a Job entity. @Entity @Table(name="Job") public class Job implements Serializable { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private int id; @ManyToOne private Job ...

What should be considered using subselects in queries with haevy loaded databases?

We are developing an application with a persistence layer using OpenJPA1.1 and an Oracle DB as backend storage. I will use queries with subselects (see my question at Solving JPA query finding the last entry in connected list). Now my colleagues at work remark, that such queries can lead to performance problems as the database is fille...

JPA Implementations - Which one is the best to use?

Hi all, I have made use of the following JPA implementations: Hibernate, Toplink, OpenJPA Each of them has their own strengths and weaknesses. I found Hibernate the most advanced of the three except that it mixed some of its own enhancements with JPA which made it difficult to switch out to other providers. Most importantly, its que...

Logging JPA SQL with Weblogic 10.3

By looking into the Open JPA website i've found that i can log the generated SQL by using the following: <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO"/> If i try to add the above property to my persistence.xml i get the following warning from weblogic: <Warning> <J2EE> <BEA-160202> <You have specifie...

how do I change persistence.xml at run time

Hello guys, I am new to openJPA. I have a scenario where, depending upon the server where my application is running, I need to change the settings to persistance.xml. For eg. if its running on Server A, then it should use different database(different url), different password etc. and if the application is running on Server B then it sh...

How should I use Enums in Openjpa entities?

I'm trying to use an enum field in an openjpa entiy. Everything works fine unitl I try to enhance my entities which breaks with a ClassNotFound exception for the Enum type. I'm using the openjpa maven plugin to enhance the entities and the enum is declared public and is on the classpath. I'm not sure what I'm missing here. ...

JPA and PostgreSQL Network Address Types

Is there a standard way to define a JPA entity that has columns with PostgreSQL network address data types? Im using OpenJPA ...

auto generate timestamp

I have to auto generate timestamp when I am creating a new record and auto generate modified timestamp when I update a record. can anybody tell me how do I implement this. I am using openJPA. thanks in advance. ...

Spring Open JPA

Hi, I am trying to integrate Spring and OpenJpa. For every scenario the exception thrown is SAXParseException: No Content allowed in Prolog. I am aware that the issue is probably related to the xml files but all the related xmls are read and validated correctly. The spring files are parsed correctly and beans are created but the en...

Impossible null pointer

Hey, I have a real weird problem. I have 2 classes: (very important note: this is an example cause I can't paste the original code, I wrote it as text with no compiler) class B { private int num = 9; public int getNum(){ return num; } public void setNum(int num){ this.num = num; } } class A { pri...

JPA Logging in WebLogic 11g (10.3.1)

How do you enable debug logging for OpenJPA when running an application in WebLogic 11g? I tried the steps given by http://stackoverflow.com/questions/792741/logging-jpa-sql-with-weblogic-10-3, but no OpenJPA log statements appear in the server log. I have also poured over the WebLogic documentation regarding the configuration of loggi...

SELECT NEW in JPQL

I'm having an issue with a SELECT NEW query. Query q = em.createQuery( "SELECT NEW com.bcbst.odstats.ejb.RangeStats(a.folderName, SUM(a.hits)) " + "FROM ODStat a GROUP BY a.folderName"); return q.getResultList(); I get the following stacktrace when I try to run this query. RangeStats does have public methods, ...

multiple discriminator columns for persistent subclasses

Hello all, I have banged my self with a very particular problem. Using OpenJPA (KODO 4.1) is there a way to use more than one column as a discriminator column? My problem is that i have a table structure (which i have limited ability to modify of course) similar to this: Table VEHICLE EXPENSIVE_CAR CHEAP_CAR EXPENSIVE_BOAT...

How to generate JPA mapping file from the JPA annotated entity classes?

I am using openjpa runtime of JPA specification. At development time I am using annotations to configure jpa entities. At Integration, Pre-Production and and Production environment, I am using orm mapping files to configure entities. Please suggest a tool which can generate mapping files from jpa annotations, so that these mapping files ...

how to use enum with jpa as a data member of persisted entity ?

Hi, Please best practice and 'how to' for using enum with jpa as a data member of persisted entity. what is the best practice? I want to persist "C", "O" from enum. (codes). If this is not the correct approach please suggest. Enum defination is -- public enum Status{ CLOSED ("C") OPEN ("O") private final int value; private Status(fina...

Reloading of persisted entity

I'm using OpenJPA in my application as a JPA vendor. The question is theoretical or conceptual: Is there any way to tell an entity manager to load an entity from the DB rather than from it's cache? The problematic scenario: EM1.persist(Entity1) EM2.merge(Entity1) EM1.find(Entity1) <--- Entity1 is the cached version rather than the m...

JPA Detected reentrant flush

I have little problem with openjpa implementation of jpa with spring 2.5. My dao method: @Transactional public User getUserByName(final String name) { return (User) getEntityManager().createQuery("select u from User as u where u.name = :name").setParameter("name", name).getSingleResult(); } returns org.springframework.dao.InvalidD...

openJPA on Java SE

Hi guys, I try to develop JPA project on ibm RAD. And i can run it on Webpshere successfully, but the problem is my machine is quite old. So deploying in JEE container isn't reasonable.And i want to run it on JSE.But it gives following error: 94 test INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.1-SNAPSHOT 235 test INFO [m...

Am I supposed to call EntityManager.clear() often to avoid memory leaks?

I'm new to JPA/OpenJPA and I noticed that if I don't call EntityManager.clear() after i persist entities I get an OutOfMemoryError (I keep adding new entities in a loop). I'm not sure if this is the expected behavior or it's just and OpenJPA 1.2.1 glitch. So, am I required to explicitly detach the entities myself? If I'm not, it's a go...

Easiest way of programatically checking that a class has a valid JPA defintion

I'm working with many classes which are annotated with javax.persistence.Entity and the like. My project is about generating metadata about JPA-annotated classes rather than persistence by itself, so I'm using them as test cases. Rather than firing up Hibernate or some other JPA provider, I'd like to programatically check - part of my u...