-->
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: Custom types registration
PostPosted: Mon Jul 29, 2013 9:05 pm 
Newbie

Joined: Fri Nov 02, 2012 12:13 am
Posts: 4
Hi,

This question has been asked a few times before with no solution, but that was a while ago so I'll give it a shot anyway.

I need to register a user-defined type as the default when no explicit type mapping exists. Same as the example shown in the Hibernate 3.6 documentation (section 6.4.1)
  • http://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/types.html#types-custom-type

The catch is that I'm using JPA around Hibernate so don't have obvious access to the "org.hibernate.cfg.Configuration" instance. I've dug through the code a bit, but haven't found an obvious way to do this yet. Is there any way to:
  • Get access to the "org.hibernate.cfg.Configuration" or "org.hibernate.type.TypeResolver" instance in a JPA-initialised application; or
  • Register types using a system property of some kind in the "persistence.xml"

Old versions of this question:
  • https://forum.hibernate.org/viewtopic.php?f=1&t=1012460
  • https://forum.hibernate.org/viewtopic.php?f=1&t=1011906
  • https://forum.hibernate.org/viewtopic.php?f=1&t=1011659


Top
 Profile  
 
 Post subject: Re: Custom types registration
PostPosted: Tue Jul 30, 2013 12:37 am 
Newbie

Joined: Fri Nov 02, 2012 12:13 am
Posts: 4
So for the time being I've decided to forego the type override and manually annotate my properties with @Type.

For anybody where this is not an option, the only approach I could see for registering type overrides through JPA is:
  • Subclass HibernatePersistence and override the create[Container]EntityManagerFactory(...) methods
  • Get the Configuration instance through the Ejb3Configuration.getHibernateConfiguration() method
  • Ignore the big scary warning on that method and register your types through that Configuration instance anyway

Far too ugly for my liking, and I have relatively few instances of the type in question.

If anybody has a better solution for achieving what the example in section 6.4.1 does using JPA, I (and I'm sure others) would really love to hear it.


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.