You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Ben Maisano <bm...@andera.com> on 2013/05/08 23:13:05 UTC

LazyInit exception with hibernate integration

Hi DeltaSpike users,
                I am thinking of using deltaspike once it comes out of beta, however right now we are using seam 3.  I thought this best list to ask about this question besides hibernate forums.  If anyone can help with ideas for what to look for related to the details in this post please let me know, thank you.

https://forum.hibernate.org/viewtopic.php?f=1&t=1026107


Benjamin Maisano

RE: LazyInit exception with hibernate integration

Posted by Ben Maisano <bm...@andera.com>.
FYI we have figured out the issue.   I put below in hibernate post, thanks for the responses.

When we tried to turn on our EntityManagerFactory producer class we were producing entity manager and entity manager factory. That caused weld duplicate producer exception, so we had it off thinking seam included this. It turns out we should only produce entity manager factory not entity manager, which makes sense. Below is working...though it seems weird we need to add this in our application code at all, and its not build into some seam jar.

@Named
@ApplicationScoped
public class EntityManagerHandler {

@SuppressWarnings("unused")
@ExtensionManaged
@Produces
@PersistenceUnit(unitName="pu1")
@Dependent
private EntityManagerFactory entityManagerFactory;

public void setupEntityManager(
@Observes SeamManagedPersistenceContextCreated event) {

Session session = (Session) event.getEntityManager().getDelegate();
LogManager.info(
EntityManagerHandler.class,
"Seam Managed Persistence COntext created for entity manager:"
+ event.getEntityManager() + "\nsession:"
+ session.toString());

}


-----Original Message-----
From: Christian Beikov [mailto:christian.beikov@gmail.com] 
Sent: Wednesday, May 08, 2013 5:44 PM
To: deltaspike-users@incubator.apache.org
Subject: Re: LazyInit exception with hibernate integration

As written in the forum post this might be related to the scope of the EntityManager which indeed could have changed when moving away from seam. I would need more insight into your code to be able to give you a better answer or hint.

Mit freundlichen Grüßen,
------------------------------------------------------------------------
*Christian Beikov*
Am 08.05.2013 23:40, schrieb Ben Maisano:
> Thanks Christian.  Well site says seam 3 no longer supported (recent change?) so I thought this is my best option besides hibernate forum.  Note this was all working, same mappings, on seam 2.  hibernate.initialize and fetch.eager do solve problem.  The issue is we have a large dependent entity model and to change everything to fetch.eager is not an option for us.
>
> -----Original Message-----
> From: Christian Beikov [mailto:christian.beikov@gmail.com]
> Sent: Wednesday, May 08, 2013 5:34 PM
> To: deltaspike-users@incubator.apache.org
> Subject: Re: LazyInit exception with hibernate integration
>
> Answered you in forum, but I don't quite understand what this has to do with deltaspike...
>
> Mit freundlichen Grüßen,
> ----------------------------------------------------------------------
> --
> *Christian Beikov*
> Am 08.05.2013 23:13, schrieb Ben Maisano:
>> Hi DeltaSpike users,
>>                   I am thinking of using deltaspike once it comes out of beta, however right now we are using seam 3.  I thought this best list to ask about this question besides hibernate forums.  If anyone can help with ideas for what to look for related to the details in this post please let me know, thank you.
>>
>> https://forum.hibernate.org/viewtopic.php?f=1&t=1026107
>>
>>
>> Benjamin Maisano
>>


Re: LazyInit exception with hibernate integration

Posted by Christian Beikov <ch...@gmail.com>.
As written in the forum post this might be related to the scope of the 
EntityManager which indeed could have changed when moving away from 
seam. I would need more insight into your code to be able to give you a 
better answer or hint.

Mit freundlichen Grüßen,
------------------------------------------------------------------------
*Christian Beikov*
Am 08.05.2013 23:40, schrieb Ben Maisano:
> Thanks Christian.  Well site says seam 3 no longer supported (recent change?) so I thought this is my best option besides hibernate forum.  Note this was all working, same mappings, on seam 2.  hibernate.initialize and fetch.eager do solve problem.  The issue is we have a large dependent entity model and to change everything to fetch.eager is not an option for us.
>
> -----Original Message-----
> From: Christian Beikov [mailto:christian.beikov@gmail.com]
> Sent: Wednesday, May 08, 2013 5:34 PM
> To: deltaspike-users@incubator.apache.org
> Subject: Re: LazyInit exception with hibernate integration
>
> Answered you in forum, but I don't quite understand what this has to do with deltaspike...
>
> Mit freundlichen Grüßen,
> ------------------------------------------------------------------------
> *Christian Beikov*
> Am 08.05.2013 23:13, schrieb Ben Maisano:
>> Hi DeltaSpike users,
>>                   I am thinking of using deltaspike once it comes out of beta, however right now we are using seam 3.  I thought this best list to ask about this question besides hibernate forums.  If anyone can help with ideas for what to look for related to the details in this post please let me know, thank you.
>>
>> https://forum.hibernate.org/viewtopic.php?f=1&t=1026107
>>
>>
>> Benjamin Maisano
>>


RE: LazyInit exception with hibernate integration

Posted by Ben Maisano <bm...@andera.com>.
Thanks Christian.  Well site says seam 3 no longer supported (recent change?) so I thought this is my best option besides hibernate forum.  Note this was all working, same mappings, on seam 2.  hibernate.initialize and fetch.eager do solve problem.  The issue is we have a large dependent entity model and to change everything to fetch.eager is not an option for us.

-----Original Message-----
From: Christian Beikov [mailto:christian.beikov@gmail.com] 
Sent: Wednesday, May 08, 2013 5:34 PM
To: deltaspike-users@incubator.apache.org
Subject: Re: LazyInit exception with hibernate integration

Answered you in forum, but I don't quite understand what this has to do with deltaspike...

Mit freundlichen Grüßen,
------------------------------------------------------------------------
*Christian Beikov*
Am 08.05.2013 23:13, schrieb Ben Maisano:
> Hi DeltaSpike users,
>                  I am thinking of using deltaspike once it comes out of beta, however right now we are using seam 3.  I thought this best list to ask about this question besides hibernate forums.  If anyone can help with ideas for what to look for related to the details in this post please let me know, thank you.
>
> https://forum.hibernate.org/viewtopic.php?f=1&t=1026107
>
>
> Benjamin Maisano
>


Re: LazyInit exception with hibernate integration

Posted by Christian Beikov <ch...@gmail.com>.
Answered you in forum, but I don't quite understand what this has to do 
with deltaspike...

Mit freundlichen Grüßen,
------------------------------------------------------------------------
*Christian Beikov*
Am 08.05.2013 23:13, schrieb Ben Maisano:
> Hi DeltaSpike users,
>                  I am thinking of using deltaspike once it comes out of beta, however right now we are using seam 3.  I thought this best list to ask about this question besides hibernate forums.  If anyone can help with ideas for what to look for related to the details in this post please let me know, thank you.
>
> https://forum.hibernate.org/viewtopic.php?f=1&t=1026107
>
>
> Benjamin Maisano
>