-->
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.  [ 7 posts ] 
Author Message
 Post subject: How to: Hibernate Criteria API and EJB 3.0
PostPosted: Fri Oct 27, 2006 6:09 pm 
Newbie

Joined: Mon Oct 16, 2006 10:36 am
Posts: 14
Location: Fort Worth, TX
I try to figure out how to utilize the powerful api in EJB3.0 environment where Hibernate is hidden. Thanks for your comments.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 28, 2006 3:13 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
((Session)entityManager.getDelegate()).createCriteria()


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 1:51 pm 
Newbie

Joined: Mon Oct 16, 2006 10:36 am
Posts: 14
Location: Fort Worth, TX
Obviously, if we do that, the ejb 3.0 application is no longer server independent, which means the server has to have the hibernate pm.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 04, 2006 4:52 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
How else should it work? If a specification doesn't have a _feature_ you need, use a vendor extension. Why else would you have decided for a particular vendor and a particular implementation? Not only because it implements the specification, but also because it has extensions that are relevant for your application.

This mindset that vendor extensions are evil was what led to the nightmare and stagnation of EJB 1 and EJB 2. Stop it, embrace the product you decided to use. Absolute portability is not your primary problem, writing working and maintainable software is.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 25, 2007 12:40 pm 
Newbie

Joined: Thu Jan 25, 2007 12:32 pm
Posts: 6
The following did not work for me...

christian wrote:
((Session)entityManager.getDelegate()).createCriteria()



However this worked form me:

Code:
HibernateEntityManager hem = ((HibernateEntityManager)em.getDelegate());
Session session = hem.getSession();
results = session.createCriteria(Book.class).list();


I hope this helps.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 26, 2007 4:52 pm 
Regular
Regular

Joined: Mon Nov 14, 2005 7:33 pm
Posts: 73
I have to agree w/ Christian.

The Criteria API was not included in the EJB 3.0 spec, so if that's what you intend to use, you'll obviously have to go outside of the spec.

Honestly - and I don't think I'm alone here, portability should be the least of your concerns. If you're hopping app-servers, or heck, switching at all then you are part of a minority and the problem then doesn't lie in the spec but rather in the decisions your team made when designing the application.

Portability is vastly overrated and even if you stick to the spec, I'm sure you'll find several other "portability" problems anyhow. There are enough holes in the spec to allow varying behavior between fully compliant app servers.

For example - moving from Glassfish to JBoss was *anything* but a no-brainer for me, and I stayed 100% within the EJB 3.0 spec.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 29, 2007 4:10 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
jbandi wrote:
The following did not work for me...

christian wrote:
((Session)entityManager.getDelegate()).createCriteria()



However this worked form me:

Code:
HibernateEntityManager hem = ((HibernateEntityManager)em.getDelegate());
Session session = hem.getSession();
results = session.createCriteria(Book.class).list();


I hope this helps.


A bug has been opened on JBoss EJB 3.0 check their JIRA isse to see if it is still open

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.