Вопрос

I have a big database divided in several schemas. From eclipse wizard (JPA Tools) I generate the JPA Entities of one schema, but there are some tables with dependencies on other tables in other schemas, and the problem is that those entities are created like this:

//Foreign Key of one table in other schema
@Column(name="TABLE_ID")
private BigDecimal tableId;

And I think it must be generated this way:

//Foreign Key of one table in other schema
@JoinColum(name="TABLE_ID")
private TableClass tableId;

Is the second way more correct than first one? Is there any way to generate automatically the JPA Entities in the second way??

Это было полезно?

Решение

Ids are generated instead of actual entity relationships when there is no visibility to the TableClass from the jdbc connection.. creating public synonyms (or equivalent) to these tables might help. This kind of behaviour can be observed with reverse engineering even when tables are chosen selectively. entity realationships to unselected tables would typically be generated in the fashion that you are currently experiencing

for e.g. for there are two tables Person and Address and a link from Address to Person..

selecting both Person and Address would generate a proper entity relatioship in Address like

private Person person;

On the other hand, selecting just Address will simply create a mapping to the raw type as the Person entity is not generated by JPA Tools

private BigDecimal personId;

which is what seems to be happening in your case

`

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top