ObjectDB ObjectDB

Changes in detach behaviour?

#1

Hello!

Today i upgraded to 2.3.5_04. My program stopped working. After some debugging i found out that all fields of retrieved objects are on their default value till i first call a getter or detach them explicitly. Up to 2.3.4 they where initialized immediately. The problem in my case is that i have a Spring DAO.

It does the following:

I call for example getUserByName("blub).

  • Spring creates an em and starts a transaction.
  • I get the desired user.
  • I return the user.
  • Spring closes the transaction and the em.

With 2.3.5_04 I get an empty detached user object back. Only the id is correct.
Shouldn't the detach and field population happen implicitly during em.close()?

edit
delete
#2

The last builds include fixes for some fetch issues so it is possible that ObjectDB behaves differently now.

But you shouldn't expect em.close() to populate data. Only data that was already populated before close will be available after close. I would expect, however, to see at least simple fields loaded automatically. Loading of collections may require setting EAGER fetch explicitly.

How is getUserByName implemented? Can you provide a simple test case that demonstrates the problem as explained in the posting instructions? You can simulate the effect of Spring transactions by closing and reopening the EntityManager.

ObjectDB Support
edit
delete
#3

I have written a demo program to demonstrate the new behaviour. While writing it i found out that it only happens whén I use the enhancer at compile time. I haven't tried it with the agent. To make it easy for you to try i created a Netbeans project with a customized build.xml to enhance the classes. If you run the project you'll see the output "null". If you use version 2.3.4 then the output is "username". I think lazy fetching of primitive fields is a bit to much.

edit
delete
#4

Thank you for this report and for the test project (small comment: no need to wrap a single class test in a project even if enhancement is required, posting it as embedded source code instead of as an attachment is preferred).

Please try build 2.3.5_05 that should fix this issue.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.