-
1. Re: foreign key columns along with associations with hibernate reverse engineering
maxandersen Oct 3, 2013 8:23 AM (in response to surkov)You need to provide a bit more details.
What are you seeing today and what is it you expect ?
What table layout are you using ?
-
2. Re: foreign key columns along with associations with hibernate reverse engineering
surkov Oct 3, 2013 12:36 PM (in response to maxandersen)Sorry i it was a mistake in JoinColumn
My tables are:
create table document (id int);
create table document_status(
id int,
documents_fk int);
alter table document_status add constraint ttt foreign key (documents_fk) references document (id);
now after generation i have in the DocumentStatus class
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DOCUMENTS_FK", nullable = false)
private Document document;
or if i use MyReverseEngineeringStrategy excludeForeignKeyAsCollection
i will have simple field without any association
@Column(name = "DOCUMENTS_FK", nullable = false)
private Long documentFk;
but my goal is to get both of them in DocumentStatus class
it is convenient in some cases
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DOCUMENTS_FK", nullable = false)
private Document document;
and
@Column(name = "DOCUMENTS_FK", nullable = false, updatable = false, insertable = false)
private Long documentFk;
-
3. Re: foreign key columns along with associations with hibernate reverse engineering
maxandersen Oct 4, 2013 9:53 AM (in response to surkov)You can adjust the .ftl templates to get this if you want.
But i'm pretty sure one of the sides will just be ignored by JPA though.