-->
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: [help] How to set hibernate naming strategy in config xml?
PostPosted: Tue Feb 23, 2010 5:56 pm 
Newbie

Joined: Fri Jan 22, 2010 11:26 am
Posts: 3
Please help: I am having troubles to set Hibernate naming strategy in its configuration xml file. What I did was

1. First created a new class
public class TestNamingStrategy extends DefaultNamingStrategy {

2. Now if I try to set the naming strategy through code like below, everything works fine and my own naming strategy got applied:
org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration();
cfg.setNamingStrategy(new test.hybertest.TestNamingStrategy());
cfg.configure(configfile);

3. But what I really needed was to specify possible naming strategies through hibernate configuration xml. I tried both
<property name="hibernate.NamingStrategy">test.hybertest.TestHbNamingStrategy</property>
<property name="hibernate.ejb.naming_strategy">test.hybertest.TestHbNamingStrategy</property>
Nothing seems to be working. Could anyone please help?

Super Thanx!


================ My Hibernate Config XML =======
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/fileDB?useUnicode=true&amp;characterEncoding=UTF-8</property>
<property name="hibernate.connection.username">test</property>
<property name="hibernate.connection.password">test</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.connection.useUnicode">true</property>
<property name="hibernate.connection.characterEncoding">UTF-8</property>
<property name="hibernate.connection.charSet">UTF-8</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<property name="current_session_context_class">thread</property>

<property name="hibernate.NamingStrategy">test.hybertest.TestHbNamingStrategy</property>
<property name="hibernate.ejb.naming_strategy">test.hybertest.TestHbNamingStrategy</property>
<mapping resource="test/hybertest/Person.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject: Re: [help] How to set hibernate naming strategy in config xml?
PostPosted: Tue Feb 23, 2010 6:20 pm 
Newbie

Joined: Fri Jan 22, 2010 11:26 am
Posts: 3
OK, found this:

viewtopic.php?f=1&t=934731&view=next

Seems like the Naming Strategy can not be set through hibernate.config.xml.


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.