jpa

Is it possible using JPA to stream results from javax.persistence.Query.getResultList() ?

Hello, I'm new to JPA and I'd like to know if it is possible to stream data from a result set, I mean I do not want to wait that the query is performed to start dealing with first results, for instance in the case of a batch. Is there any possibility using the JPA API or any community adopted workaround ? Eventually using a feature of ...

Google App Engine - can't operate on multiple entity groups in a single transaction

Why am I receiving the exception below if the type of both entities is PersistentLogin? I thought that would mean they are in the same entity group, but I guess that is an incorrect assumption. Any ideas how to fix this? This is the code: // the class is marked with @Transactional @Override public final void removeUserTokens(final Stri...

How do I use Spring's IdToEntityConverter to do my Entity Type Conversion during form binding?

I'm sick of writing extending PropertyEditorSupport for every single Entity in my system. I notice that Spring 3.0 has an IdToEntityConverter, but there is really not much documentation on how to use it. Please comment on the best generic way to convert between id and entity. ...

Hibernate performs a Delete on a Select

Hi Guys, I'm facing a problem with Hibernate. My current project is a little game. In this game you have a Board which has many Fields each with a Token. I can make a select on an empty database without any problems but if I put one object into it (saving works without any exceptions and after it the database values looks good) I'm getti...

How do I embed a String Array into an Entity (JPA)

I wanna design an Entity Class which has a String[] property. This String Array always has two values and I dont want Hibernate (or rather JPA) create an extra table for this but embed this two String values directly into the table. Is this possible and if so how? ...

how to store weather data with JPA

The project is required to sotre large weather data (http://www1.ncdc.noaa.gov/pub/data/igra/) into file system with JPA. I mean disk files. How to store those data. For example, how to organize the files? So that we can retrieve those files for retrieving. Thanks very much ...

Use of Hibernate 3.0 with EJB 3.0 & JPA

Where I'm working the guys that are sitting across from me are working on a project. This is a JavaEE app which uses Struts, Spring, EJB 3.0, JPA, and Hibernate 3.0. They are using EJB 3.0 entity beans with annotations. I've been asking them why Hibernate 3.0 is in this mix and noone can seem to tell me. It feels like they've include...

What orm.xml features should be avoided to stay database agnostic?

I'm embarking on an adventure in JPA and want to, inasmuch as possible, stay database agnostic. What orm.xml features should I avoid to stay database agnostic? For example, if I use strategy="AUTO" in orm.xml as follows: <id name="id"> <generated-value strategy="AUTO" /> </id> ...then MySQL shows it as an AUTO_INCREMENT column w...

Entity members should they be primitive data types or java data types?

Is there a difference in declaring the enabled variable as Boolean or boolean? Which is preferable from a memory footprint perspective. @Entity class User { @Column Boolean enabled; } ...

"cascading" a hibernate entity listener?

Hi, Using hibernate 3.2.4.sp1 I have two entities User and ContactInfo A User has a related ContactInfo, relation is unidirectional, i.e. ContactInfo has no idea about the user it belongs to (nor should it as it is reused in other relations) The User entity has an entity listener preventing other users than the actual user itself t...

Hibernate, instrumentation and delete cascade order

I have a complex object graph with JPA connected entities. When I delete the parent the deletions cascade correctly to the children. Then I instrument the parent class (as to not load eagerly one-to-one relationships) and upon deletion I get referential integrity violation exceptions. Looking at the queries hibernate issues upon flush,...

Updating JPA-Hibernate entity without selecting it from database

I have a hibernate entity called Execution. It is created in the beginning of my process and updated at end, indicating how it has finished. I would like to update a single property of this entity, without causing a select in my database. Execution execution = entityManager.getReference(Execution.class, executionId); execution.setSta...

Create new or update existing entity at one go with JPA

A have a JPA entity that has timestamp field and is distinguished by a complex identifier field. What I need is to update timestamp in an entity that has already been stored, otherwise create and store new entity with the current timestamp. As it turns out the task is not as simple as it seems from the first sight. The problem is that i...

How to share EntityManagerFactory Object across the various Resource files in a Restlet application?

I would like to create one EMF object and use it in various Resource class objects.. any ideas on how to do this? ...

How to retrieve mapping table name for an entity in JPA in runtime?

Is it possible to determine the native table name of an entity? If Table annotation is present it's easy: entityClass.getAnnotation(Table.class).name() But is it possible to get the table name, if no Table annotation is present? Hibernate provides the information via Configuration https://www.hibernate.org/hib_docs/v3/api/org/hibern...

jpaTamplate how to autocommit...?

I am using JPA i have setup transaction on service layer using @Transactional.. it is working fine.. but when i test Dao (Junit) transactions using JpaTemplate are not getting commited.. although same test with JdbcTemplate were getting comitted... So how to enable auto-commit for JpaTemplate...? ...

Why JPA, Hibernate and jTDS always uses varchar(8000) for String columns?

I'm using JPA (Hibernate) and jTDS as my jdbc driver. Whenever the datatype of my entity columns are String, the created prepared statement uses varchar(8000) as its parameter. I've already tried to use @Column(length=50) in my mappings for example, but it seems to be ignored. If I set sendStringParametersAsUnicode in jTDS connection, i...

How is JPA and Memcached different?

[UPDATED] Hi, I am trying to figure out the difference between Memcached and JPA, this is what I infer from the information I have Memcached: Cache data and objects in memory, like an on the fly database to quickly access the data. This layer is just above the actual db (say my sql). It has its own columns and rows, where can you kee...

JPA property java.net.URL

HI, I have an object which has a piece of URL-Information associated with it. Currently I save this URL in a simple String property, but java.net.URL would provide me with additional goodies such as detection of malformed URLs etc. On the other hand I would consider it very ugly, if JPA simply created a LOB for the URL-Object. Does an...

JPQL Create new Object In Select Statement - avoid or embrace?

I've learnt recently that it is possible to create new objects in JPQL statements as follows: select new Family(mother, mate, offspr) from DomesticCat as mother join mother.mate as mate left join mother.kittens as offspr Is this something to be avoided or rather to embrace? When is usage of this feature justified in the light ...