Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate naming strategy problem

 
ayan sevi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, hibernate newbie here. I'm having problem with the use of naming strategy, wherein according to hibernate docs, it should generate a foreign key column name with the format "name of the relationship in the owner side, _ (underscore), and the name of the primary key column(s) in the owned side", i.e. entity_id. When naming strategy was not specified leaving hibernate to use DefaultNamingStrategy, it behaves correctly, but when I tried to specify the naming strategy, this time with ImprovedNamingStrategy, it generates wrong column name, i.e. expected was "entity_id", it only generates "entity".

I'm using Maven2 plugin hbm2ddl for generating the schema.

Hibernate version: hibernate-3.2.1.ga, hibernate-annotation-3.2.1.ga

The generated SQL (show_sql=true):

alter table gateway_type_test
drop constraint FKB0101E3CA31F223D;

drop table gateway_test;

drop table gateway_type_test;

create table gateway_test (
id int identity not null,
name varchar(255) not null,
description varchar(255) null,
ssl tinyint not null,
port int not null,
user_name varchar(255) null,
password varchar(255) null,
sms_api_id varchar(255) null,
primary key (id)
);

create table gateway_type_test (
id int identity not null,
name varchar(255) not null,
gateway int null,
primary key (id)
);


alter table gateway_type_test
add constraint FKB0101E3CA31F223D
foreign key (gateway)
references gateway_test;



Thanks.
 
ayan sevi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone who has thoughts on this???
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show us your mapping and we will show you ours.

And maybe your NamingStrategy code.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic