tags:

views:

31

answers:

1
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn (name = "account_id")
private Account account;

Works fine.

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn
private Account account;

Exception : Missing column account in SomeSchema.SomeOwnerTable

*

JPA Spec says default join column name is property name ( 'account') + '_' + target table primary key ( 'id' ).

But it looks like hibernamte searching just property name 'account' instead of 'account_id'.

Any comment ?

Thank you.

+2  A: 

I think you can safely get rid of the @JoinColumn annotation - there's a join column anyway.

Also, make sure you haven't configured a specific naming strategy, that may override the default behaviour.

Bozho
I'm using ImprovedNamingStrategy. ImprovedNamingStrategy converts, for example, Account -> account, accountId -> account_id.
drypot
ImprovedNamingStrategy was the problem. Thank you. http://matthew.mceachen.us/blog/hibernate-naming-strategies-20.html
drypot
+1 Nice one (pad)
Pascal Thivent