|Migrating from Hibernate to EclipseLink [message #1228503]
||Tue, 07 January 2014 11:20
| Sendhil Kumar
Registered: January 2014
I am new to Eclipse Link...
I have to migrate my application from hibernate to eclipselink.
Before the actual issue, can you suggest which version of EclipseLink I could go, which is stable and widely used?
And here is my issue,
Following query am trying to execute,
SELECT x FROM UserVo x (which has 4 rows in db)
Here, the UserVo object creation is happening only when I do the following,
EntityManager entityManager = entityManagerFactory.createEntityManager();
but on actualy query execution below, no initilization of the class occurs,
Query q = entityManager.createQuery("SELECT x FROM UserVo x");
In case of hibernate , it will do initlization for indivdual entries in the table. So, if its similar, it should invoke the default constructor 4 times, but this is not happeng with case of eclipse link.
Actually I would like to inilizatize an additional attribute which is not actually in db, within this constructor, so could not able to achieve it.
Can you pls help me on this.
Let me know if you need more details.
|Re: Migrating from Hibernate to EclipseLink [message #1229041 is a reply to message #1228503]
||Wed, 08 January 2014 15:38
| Chris Delahunt
Registered: July 2009
I assume you mean that the default constructor is not being called when you actually execute the query, and are not expecting the constructor to be called on the createQuery call. |
If so, EclipseLink uses bytecode enhancement to implement optimizations. One of which is probably causing your default constructor to be bypassed, allowing EclipseLink to more efficiently create instances without initializing attributes that it will then have to replace anyway when it loads the data from the database. You can verify this by having EclipseLink write out the end result of its weaving process by running the static weaver on your classes and inspecting them with a decompiler to see how they have changed. Running static weaving is described here:
If this is related to the problem, you might try disabling internal weaving optimizations by setting the eclipselink.weaving.internal persistence property to false, as described here:
If you want to rely on non-persistence properties being set in entities though, you might be better to use a postLoad event to ensure they are they are set.
As for versions, I'd recommend always starting with the latest released to get all the latest bug fixes. No point re-diagnosing issues that have already been fix in my mind, and you get all the latest features you may not need yet, but might in the future.
Powered by FUDForum
. Page generated in 0.02459 seconds