-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate Naming Strategy
PostPosted: Tue Dec 11, 2012 9:40 pm 
Newbie

Joined: Tue Dec 11, 2012 9:19 pm
Posts: 1
I am fairly new to Hibernate. I am trying to make entities table mapping dynamic. I heard about using NamingStrategy to do that. And I am just wondering if this is the correct way to implement it?

my code looks something like this.

@Entity
public class tableMapping{.....}

my .hbm file linked to .cfg file
<class name="package.tableMapping" table="table1"/>.......</class>

Naming Strategy class
public class CustomNamingStrategy extends ImproveNamingStrategy{
@Override
public String tableToClass(String Class){
return super.tableToClass()+ "addon";
}
}

Implementing naming strategy
public void setNamingStrategy(){
Configuration cf = new Configuration();

cf.setNamingStrategy(new CustomerNamingStrategy);

cf.buildSessionFacotry();
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.