-->
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.  [ 6 posts ] 
Author Message
 Post subject: Implement UserType methods depending on Dialect
PostPosted: Thu Oct 27, 2005 4:44 am 
Newbie

Joined: Tue Oct 26, 2004 2:46 am
Posts: 3
Hello everybody...

I'd like to be able to switch behaviour of a UserType depeding on the dialect of the enclosing SessionFactory.

Is this possible at all?

How can I do that?

To be more specific:

I have a UserType that maps Strings to Oracle's FIXED_CHAR. I cannot use mapping files using that UserType on a HSQLDB because the FIXED_CHAR is unknown to HSQLDB. I could use VARCHAR as a fall-back, but how can I know if the UserType is used in a HSQLDB context or in a Oracle context?

Martin.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 10:41 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
grab hibernate Configuration and call getProperty(Environment.DIALECT)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 6:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Or use a ParameterizedUserType and provided it some appropriate parameterization info...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 28, 2005 1:15 am 
Newbie

Joined: Tue Oct 26, 2004 2:46 am
Posts: 3
snpesnpe wrote:
grab hibernate Configuration and call getProperty(Environment.DIALECT)


Perhaps I am missing something obvious, but how do I find the Configuration from UserType?

Martin.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 28, 2005 7:55 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
You need the instance of org.hibernate.cfg.Configuration.
You will have loaded it when you started you application.
It basically is created loading the hibernace.cfg.xml.
We do it like this:

Code:
Configuration cfg = new Configuration();
URL url = new URL(hibCfgUrl);
cfg.configure(url);


Perhaps there are other ways.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 28, 2005 9:17 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Quote:
Perhaps I am missing something obvious, but how do I find the Configuration from UserType?


you set own Configuration when start hibernate (for example in HibernateUtil) and call with static method

I do it with

HibenrateUtil.getConfiguration()


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