-->
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.  [ 2 posts ] 
Author Message
 Post subject: Staying mostly JPA portable, but enhancing with Hibernate?
PostPosted: Wed Jun 03, 2009 2:56 pm 
Beginner
Beginner

Joined: Thu Dec 29, 2005 12:08 pm
Posts: 31
Location: Acton, MA
I'm looking for the Hibernate team's recommendations on how to incorporate some of their extensions (specifically the Hibernate.YES_NO_TYPE) into an otherwise portable JPA project.

I come from an EclipseLink background, so to do this in EclipseLink, you put a META-INF/eclipselink-orm.xml file down and sparsely fill it only with those non-JPA-specified attributes you want to apply to your project. If EclipseLink is the persistence provider, it will recognize this file, load it up, and lay it over META-INF/orm.xml and any JPA annotations you're using.

I know that Hibernate makes use of hbm.xml files, but what I'm not sure about is their sparseness: is it possible to do the bulk of my configuration using JPA annotations and then place certain mapping attributes sparsely into hbm.xml fragments?

Specifically I'm looking to use Hibernate's type conversion utilities for boolean columns, when Hibernate is the persistence provider, EclipseLink's type conversion utilities for boolean columns when EclipseLink is the persistence provider, and so on. I'd like to do this without having to fully specify an object's mapping in XML.

Thanks for any help you can provide.

Best,
Laird


Top
 Profile  
 
 Post subject: Re: Staying mostly JPA portable, but enhancing with Hibernate?
PostPosted: Wed Jun 03, 2009 8:39 pm 
Beginner
Beginner

Joined: Thu Dec 29, 2005 12:08 pm
Posts: 31
Location: Acton, MA
Quote:
I know that Hibernate makes use of hbm.xml files, but what I'm not sure about is their sparseness: is it possible to do the bulk of my configuration using JPA annotations and then place certain mapping attributes sparsely into hbm.xml fragments?


...and the answer is, no, it is not. Once Hibernate picks up an hbm.xml file it regards it as being the canonical source of mapping information.

I tried creating a DTD-conformant hbm.xml file, and put the minimum amount of mapping information in it that I could. I wanted to specify only that a given boolean field should be run through the Hibernate "yes_no" converter during mapping operations. As I realized that in order to make the hbm.xml file parse correctly I'd have to put in an <id> element, I got that sinking feeling. :-)

Sure enough, although it was discovered automatically by the Hibernate EntityManager implementation (that's cool) it was treated as though it were the be-all and end-all of mapping information for the class it described (that's not cool). That is, unlike a JPA orm.xml file, which "fills in the gaps" where annotations have not specified all the information (if metadata-complete has not been specified), the hbm.xml file seems to simply be treated as the last word on mapping information. So you have to populate it fully, not sparsely.

This means that if I want to make use of the many very useful Hibernate extensions--but if I don't want to ship with the hibernate annotations jar--then I have to create complete mapping files for all of my JPA entities. Sniff.

I would love to be proven wrong here, and am hoping someone will do so.

Best,
Laird


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