facebook

JPA reverse engineering referenced table properties missing

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #293480 Reply

    I am using JPA reverse engineering on an existing MySQL database with foreign key constraints active with the standard Toplink libraries. The resulting code picks up all the table columns (including those that are foreign keys), but does not include annotations reflecting the other table reference or new properties for getting the other object (or a list of other objects). This is true for OneToOne and OneToMany relationships.

    I did select all “Include Referenced Table” and “Generate Support for Listed/Unlisted Table” options when running the generator.

    I am using custom templates but did repeat the problem by running the generator with that turned off.

    Am I wrong to expect the code generation engine to automatically detect these relationships and create the corresponding properties? If so, how do I specify them?

    This is for MyEclipse Enterprise Workbench Version: 7.0 Build id: 7.0-20081201.

    #293502 Reply

    Brian Fernandes
    Moderator

    Richard,

    Before we go on, are you sure the relationships are part of your schema? For example, if you used the default storage engine with MySQL, the constraints would not be saved in the schema and thus not picked up by the RE process (I’m not sure of exactly what you mean by “foreign key constraints active”).

    but does not include annotations reflecting the other table reference or new properties for getting the other object (or a list of other objects). This is true for OneToOne and OneToMany relationships.

    I assume you are not getting any OneToMany or ManyToOne annotations at all (OneToOne will be supported in the next version of MyEclipse). Is this correct?

    To make sure relationships are actually part of your schema, can you select a table which is related to another table and observe the Foreign Keys and Exported Keys tab in the Table/Object Info view; do you see any keys listed?

    #293519 Reply

    I did not use the default storage engine, I used InnoDB. The foreign key constraints are being saved in the schema (and are therefore “active”). They are shown in the MySQL Administrator program. (BTW, the schema was created using a demo copy of Visual Paradigm SDE because MyEclipse does not have an ER Diagram editor that can do that.)

    There are no entries on any of the Exported Keys tabs.

    The Foreign Keys tab shows the keys, but (I just noticed) the table names there are all lower case. In the schema (and the DB Browser), they are MixedCase (like a Java class name). I am using a MySQL runtime parameter to make this so on a Windows system (for development, production is Linux). Even though there is capitalization in the table names, they are unique without it. Could that be the problem? Is there a “get foreign keys for this table” method that’s not finding any because of an equals() instead of an equalsIgnoreCase()?

    Your assumption about my not getting any OneToMany or ManyToOne annotations is correct.

    #293593 Reply

    Brian Fernandes
    Moderator

    Richard,

    Sorry for the delayed response. I spent some time researching this issue and it does seem like your mixed case tables might be causing a problem. I was able to create a couple of mixed case tables in windows (using the lower_case_tables=0 setting) and replicate your experience. Unfortunately I cannot suggest a workaround at this time; I’ve filed this as a bug and we are investigating the issue internally, it affects our DB and RE tooling; you will need to create those relationships manually.

    Sorry for the inconvenience caused, we’ll try and get this addressed in a future release.

    #293604 Reply

    Thanks Brian.

    I tried it with a fresh (first open of session, so no cached data from local db) connection to the Linux production server, which is running in MySQL’s default table name case (mixed, case-sensitive) for that platform. The Foreign Keys tab is still showing lower case names, so it seems to be more a matter of the Windows client than the database server. Hope that helps.

    Do I understand you to say that this is not a problem if MyEclipse is running on a Linux desktop talking to a local database? If so, it might make sense for me to install it on the production server to get this done. Otherwise, I’ve a good deal of editing to do.

    #293639 Reply

    Brian Fernandes
    Moderator

    Richard,

    I just tested this and if you use MyEclipse on Linux, you will see the Exported Keys and the relationships will be picked up by the reverse engineering tools. So if you can install it on your production box (or any Linux box) everything should work fine.
    I appreciate your patience with us on this matter; we’re looking at exactly where the break is on Windows.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: JPA reverse engineering referenced table properties missing

You must be logged in to post in the forum log in