users@glassfish.java.net

select after insert issue

From: Davy De Durpel <Davy.De.Durpel_at_isencia.be>
Date: Tue, 02 May 2006 17:20:55 +0200

Hi,

I have a strange behavior and I have it on build 42 and 46 (the only 2 I
tested).

The problem in short is that when I do a persist of a new entity and
then I do a select to retrieve all entities from the database, then all
referenced objects are empty (all properties are Null). No way to get
them back then restarting the application. In all other situations
(selects, updates) I don't have the problem but things go wrong as soon
as I persist a new Entity to the database.

I will try to explain in more detail.

I have a table 'Reservation' that contains a link to a table 'Asset' and
a table 'User'.
I execute this query to get all the reservations for a certain user:
'SELECT c FROM Reservation c WHERE c.user = :user'
Everything is left by default so it should be using eager fetching. The
result is correct and also the User and Asset information is retrieved
from the database.
I now create a new Reservation with some default values. I also add an
existing Asset and User object (detached from the entity manager).
I use em.persist to save the reservation in the database and I can
clearly see that this is done in a correct way.
I then execute the same query again to retrieve all Reservations for the
current user from the database but now my 'User' and 'Asset' objects
have all fields initialized to Null values.

I also tried it with other Entity beans and I have the same behavior.

Any idea what could be causing this behavior or do I need to provide
more details?

Byeee...