• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Hibernate naming strategy problem

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone who has thoughts on this???
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Show us your mapping and we will show you ours.

And maybe your NamingStrategy code.

Mark
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic