- This topic has 5 replies, 2 voices, and was last updated 17 years, 3 months ago by Riyad Kalla.
-
AuthorPosts
-
asookazianMemberUsing Eclipse 3.2.2 and MyEclipse 5.5.1 GA.
I just reverse engineered a view using JPA reverse engineering in MyEclipseIDE and the results were interesting.
The view is based on a UNION of two tables. The name of the view is GLOBAL_EMPLOYEE_MASTER. In the @Table annotation of the Entity bean class, the name attribute is “GLOBAL_EMPLOYEE_MASTER” which is not a name of an existing table. Is this OK? Can the name reference the name of a view and not a table?
Also, it looks like the contents of the GlobalEmployeeMaster.java and GlobalEmployeeMasterId.java classes are reversed (i.e. the embeddable ID class has all the variables and getters/setters from the view while the entity bean class has many @AttributeOverride entries and only getId() and setId() methods).
In the case of reverse engineering a view based on a UNION of two or more tables, how does the rev-eng engine know what columns make up a composite key?
Are these results normal in this scenario or is this a bug? thx.
Riyad KallaMemberasookazian,
This is actually all correct. You won’t be able to persist updates back to the View, but you should be able to read it.Also the reason the ID type has *all* the fields, is because the View doesn’t have a PK, and the default behavior for the persistence tools is to make a PK out of *all* the table’s fields when one is not present. This creates a composite ID, which the GlobalEmployeeMasterId class represents and the GlobalEmployeeMaster class uses to identify itself.
It just looks odd since it’s so lop-sided, but it’s what the persistence framewokr needs in order to identify fields.
asookazianMemberso how should I go about doing a SELECT (e.g., em.createQuery(…)) using these resulting files/classes?
Riyad KallaMemberDuring rev-eng you have the option of generating DAOs along with your POJOs, you can use these to perform the queries you want very quickly and easily.
asookazianMember@support-rkalla wrote:
During rev-eng you have the option of generating DAOs along with your POJOs, you can use these to perform the queries you want very quickly and easily.
how bout in the case of a JOIN?
Riyad KallaMemberAgain, you mean for a view? It shouldn’t make any difference. The rev-eng tools just see a table with fields, they treat it like anything else.
-
AuthorPosts