jpa

Is there a way to get the count size for a JPA Named Query with a result set?

I like the idea of Named Queries in JPA for static queries I'm going to do, but I often want to get the count result for the query as well as a result list from some subset of the query. I'd rather not write two nearly identical NamedQueries. Ideally, what I'd like to have is something like: @NamedQuery(name = "getAccounts", query = "SE...

How to activate datanucleus java-type extensions for JPA?

I have a simple JPA @Entity that has a property of type java.util.Locale. When I try and persist this, I get the following error: java.lang.IllegalArgumentException: locale: java.util.Locale is not a supported property type. at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue( DataTypeUtils.java:174...

persistence.xml ignores Hibernate and chooses DataNucleus

Hi, I'm toying around with GWT (dunno if this matters) and Hibernate. I've created a a file persistence.xml in META-INF with (amoung) other configuration the line: org.hibernate.ejb.HibernatePersistence But when I startup the EntityManager it chooses DataNucleus instead of Hibernate (which later fails because it isnt installed (jar are ...

JPA/Hibernate DDL generation; CHAR vs. VARCHAR

I have a JPA/Hibernate data model that I am using the Hibernate hbm2ddl tool to generate database DDL. I have some strings that should be CHAR and some that may be VARCHAR in the database. I want to minimize hand editing of the DDL (I realize that some will have to happen). Anyone know how I should go about this? I realize that I can ma...

Glassfish limited to two simultaneous threads with JPA/EJB/web service

I'm exposing the following EJB3 stateless session bean through a web service. @Stateless public class UserRoleFacade implements UserRoleFacadeLocal { @PersistenceContext(unitName = "SimpleEA-ejbPU") private EntityManager em; public int count() { System.out.println("thisClass=" + this.getClass().getSimpleName() + "@"...

Encrypting Parameters in persistence.xml

We have a batch application using OpenJPA. We are specifying all the DB connection parameters in persistence.xml. Although its a functional setup it looks very insecure to have all the ip,username,password in clear text and a serious concern in production. As it is a standalone batch app we cant use server configurations etc. Is there a...

Google App Engine - org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed

Why does the code below result in org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed? The exception appears to be thrown at query.getResultList(). public final void removeUserTokens(final String username) { final Query query = entityManager.createQuery( "SELECT p FROM PersistentLogin p WHERE user...

Defines JPA behavior for setting same value again?

I wonder, if there is any definition by JPA for the behavior, if you setting equals value for any property. I didn't find any words in the specification. I've tested with TopLink Essentials and Hibernate, what happens if I load a entity from database and set the property with same value again. @Entity public class MyEntity { @Id @G...

constraint problems using apache derby and hbm2ddl

We are using Apache Derby 10.5.3.0_1 and hbm2ddl with Hibernate 3.3.x I get the following constraints error while pre-loading the SQL on an embedded derby database. If I remove the primary key(id) from the create table sql, it's able to create the table. Not sure what the problem is over here. create table user_flow (id integer not nul...

Eclipse link jpa problem

With two users simultaneously using my simple app, I'm getting exception: Error Code: 0 Call: SELECT ID, NAME, IMAGE FROM GameObjectTable ORDER BY ID ASC Query: ReadAllQuery(referenceClass=GameObject sql="SELECT ID, NAME, IMAGE FROM GameObjectTable ORDER BY ID ASC") Caused by: org.postgresql.util.PSQLException: There was In/Out error w...

Persisting 3rd party objects with JPA

Hi everyone, In my current project I am using a 3rd party library which has no JPA annotations. Can I persist objects from that library using JPA and external mappings? Can you recommend a good example? So far I only found information on external XML-Mappings and JPA in the JSR220 spec which mostly states the structure of the mappings....

How do I connect to multiple databases using JPA?

I have an application using Java servlets/JSP's. There are multiple clients using my app, however each client has a separate database. All the databases have the same schema. I would like to determine which database connection to use at the time when a user logs into the system. For example client A logs in, I determine that client A b...

Persisting non-entity class that extends an entity (jpa) - example?

The JPA tutorial states that one can have a non-entity that extends entity class: Entities may extend both entity and non-entity classes, and non-entity classes may extend entity classes. - http://java.sun.com/javaee/5/docs/tutorial/doc/bnbqa.html Is it possible to persist such structure? I want to do this: @Entity abstract...

How does Jpa Query.setParameter work with MetaValue (polymorphic query)?

Hi, I've been trying to use polymorphic query with JPA (hibernate as provider) in the following domain scenario: PriceTable (1) <--->(n) ItemPrice (n) <----> (1) Item So for each PriceTable registered in my system I have a set of item prices which describe the price of a given item on that table. An item can be an Equipment or a Struc...

How should I secure my webapp written using Wicket, Spring, and JPA?

So, I have an web-based application that is using the Wicket 1.4 framework, and it uses Spring beans, the Java Persistence API (JPA), and the OpenSessionInView pattern. I'm hoping to find a security model that is declarative, but doesn't require gobs of XML configuration -- I'd prefer annotations. Here are the options so far: Spring S...

Problem with JPA Order By and swedish characters

I am experiencing a problem with order by in a JPA-query. The query is trivial and behaves as expected in an sql-client. The problem is the swedish characters å, ä and ö (should be in that order). When running the query through JPA (Hibernate) å and ä are in the wrong order (ä,å,ö). There is no difference between Oracle and HslqDB and n...

ORA-22835 using JPA (Buffer too small)

I am trying to persist an Entity with a @Lob annotated String field. The content of that fiels if bigger than the 40k buffer size limit. The first problem I had was related to the setString method used internally by the JPA implementation (Hibernate in my case) and the Oracle JDBC Driver. This problem was solved adding <property n...

JPA merge problem

In my spring/openjpa based application, I have two simple entities: @Entity public class Game { @Id @GeneratedValue protected Long id; @ManyToOne(cascade={CascadeType.PERSIST,CascadeType.MERGE}) @JoinColumn(name = "target_id") protected GameObject target; ...} @Entity public class GameObject { @Id @GeneratedValue protected Long id; @...

How do I configure Spring Security 2 database authentication with Hibernate 3 Annotated Classes?

Hi, I'm building an app using Hibernate 3 (with JPA Annotations), Spring 2.5 and Spring Security 2.0.5. I want to know what I need to put in my <authentication-provider> tag in my spring security config file (applicationContext-security.xml) so that I can get Spring Security to use my existing Service layer class (AuthenticationService...

EclipseLink JPQL (Glassfish v3): join fetch syntax problem?

Hi guys, With Hibernate I'm used to do something like the following: select n from NetworkElement n join fetch n.site s where s.active is true However, EclipseLink complains a lot about this: Caused by: Exception [EclipseLink-8024] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.JPQLExcept...