I was getting a very similar error when I tried to access objects in a relationship and got an instance with the "EnhancerByCGLIB"
It seems like a very complex issue but appears to be related to whether the relationship is LAZY and whether you have to rely on the EntityManager to load the object for you. It also seems to be connected with crossing multiple session bean boundaries where you implicitly work with different entity managers. In my case, I had a session bean method that called other session beans to retrieve data and then later update it. Most of my relationships are loaded LAZILY however if I know I want it eager, I use INNER JOIN FETCH in my query. In this case, I loaded a particular entity, DeviceInterface, that was related to an entity, IpAddress, as an N-1. Since I didn't need the IpAddress at the time, I didn't explicitly load it. However, the EntityManager seems to have generated this EnhancerByCGLIB class for it. Later when I ran another query specifically to get this IpAddress, I would get the mapping exception when I tried to do an update. I also had this problem on another entity. I found three things that avoided the error: 1. Remove the transaction on the outer session bean method. When not in the transaction, all the objects became detached and I always relied on a fresh entity manager. 2. In my initial query, I would use INNER JOIN FETCH to eagerly load all the objects I would need for the entire transaction, even if I didn't need them right away. 3. Make that IpAddress relationship EAGER. In any case, I got my code to work, however I'm not particularly satisfied with the solution because I would like to understand why this is happening and come up with a general coding strategy that will consistently avoid this problem without also making everything load eagerly. Otherwise, it's a real hit-or-miss situation where I just respond to the error whenever I see it. And I don't particularly like to be in that position. Jon View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3910091#3910091 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3910091 ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ JBoss-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-user
