-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Concurrent use of native Hibernate API
PostPosted: Sat Apr 21, 2007 11:43 am 
Beginner
Beginner

Joined: Sat Jan 31, 2004 7:19 pm
Posts: 39
Is it posible to use Hibernate a JPA provider and concurrently continue
using the Hibernate-3 API?

What happens to entities of the same name?

I am getting a DuplicateMappingException

Despite using the same Hibernate core code, I would maintain that
there should be no naming conflict possible between these separate domains.
Is this a valid assumption?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 12:46 am 
Newbie

Joined: Sun Apr 22, 2007 12:57 am
Posts: 7
Quote:
Is it posible to use Hibernate a JPA provider and concurrently continue
using the Hibernate-3 API?

Yes. The Hibernate EntityManager is also instanceof HibernateEntityManager and you can get hibernate session by calling getSession() method on HibernateEntityManager cast.

Quote:
What happens to entities of the same name?

Either user EJB3 annotation or Hibernate mapping. You can mix and match both styles for entities. However, you can't use both for an entity.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 6:15 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
(Session) entityManager.getDelegate();
is the preferred way to get the underlying session.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 11:34 am 
Newbie

Joined: Mon Apr 23, 2007 10:22 am
Posts: 5
emmanuel wrote:
(Session) entityManager.getDelegate();
is the preferred way to get the underlying session.

I've read that in many places, but was unable to get it to work. I'm using the latest hibernate core, annotations and entitymanager on Glassfish. What I ended up getting to work was

Code:
Session session = ((HibernateEntityManager) em.getDelegate()).getSession();


Even the netbeans wiki page about using the hibernate session with JPA (on glassfish) shows doing it the way emmanuel said.

I feel like a must be missing something. Hopefully I can revisit this sometime.

Regards,

-james.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 1:11 pm 
Beginner
Beginner

Joined: Sat Jan 31, 2004 7:19 pm
Posts: 39
Quote:
What happens to entities of the same name?

Either user EJB3 annotation or Hibernate mapping. You can mix and match both styles for entities. However, you can't use both for an entity.[/quote]

I think you meant: you can't use the same entity-name for both
mappings, which is what we were doing.

I still hope we can use a different entity name and use the same underlying class from Hibernate and JPA, or can't I?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 24, 2007 4:20 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
jstansel wrote:
emmanuel wrote:
(Session) entityManager.getDelegate();
is the preferred way to get the underlying session.

I've read that in many places, but was unable to get it to work. I'm using the latest hibernate core, annotations and entitymanager on Glassfish. What I ended up getting to work was

Code:
Session session = ((HibernateEntityManager) em.getDelegate()).getSession();


Even the netbeans wiki page about using the hibernate session with JPA (on glassfish) shows doing it the way emmanuel said.

I feel like a must be missing something. Hopefully I can revisit this sometime.

Regards,

-james.


This s a bug in Glassfish, we had the same in JBoss AS some times ago.
http://jira.jboss.com/jira/browse/EJBTHREE-687

Please report that as a bug in Glassfish, so that they fix it. We need to clarify the spec anyway.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 3:02 pm 
Newbie

Joined: Mon Apr 23, 2007 10:22 am
Posts: 5
emmanuel wrote:
emmanuel wrote:
(Session) entityManager.getDelegate();
is the preferred way to get the underlying session.

jstansel wrote:
I've read that in many places, but was unable to get it to work. I'm using the latest hibernate core, annotations and entitymanager on Glassfish.

Please report that as a bug in Glassfish, so that they fix it. We need to clarify the spec anyway.

Today I installed the lastest glassfish promoted build, v2-b44, and still see the same error.

Code:
java.lang.ClassCastException: org.hibernate.ejb.EntityManagerImpl

I don't see an existing bug filed in glassfish for this so I'll try to add one, and reply here with issue number.

-james.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 3:32 pm 
Newbie

Joined: Mon Apr 23, 2007 10:22 am
Posts: 5
jstansel wrote:
and reply here with issue number.

glassfish issue 2923: https://glassfish.dev.java.net/issues/s ... gi?id=2923


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.