facebook

Hibernate relationships incorrect with Oracle driver

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 15 posts - 16 through 30 (of 36 total)
  • Author
    Posts
  • #241253 Reply

    Daniel Ray
    Member

    BTW .. The OCI problem is only an issue with Java 5.0. Java 1.4 works just fine.

    #243940 Reply

    Daniel Ray
    Member

    This problem perists with

    Version: 3.1.0
    Build id: I20050627-1435

    Version: 4.0.200
    Build id: 20051205-4.1-Milestone2

    #244209 Reply

    Daniel Ray
    Member

    4.1M2 has three (more) bugs.

    1. Does not generate FK relationships.
    2. Subclass is wiped out when new Abstract class is created.
    3. Hibernate.cfg is not getting updated.

    #244216 Reply

    Riyad Kalla
    Member

    budoray,
    I sent these to the hibernate team ASAP to look into, thank you for reporting them.

    #244221 Reply

    Riyad Kalla
    Member

    budoray,
    1) Do you see any errors in your log file near the bottom related to this? (<workspace dir>\.metadata\.log)
    2) In the example of table “business” that generates AbstractBusiness.java and Business.java, are you saying that Business.java is wiped out each time you regenerate?
    3) To clarify, this is not getting updated when you regenerate the mappings, or did you mean something else?
    4) Are you using the Oracle OCI or thin driver? If you are using OCI, can you try the thin (Type 4)?

    #244228 Reply

    Daniel Ray
    Member

    1. None
    2. Yes. AbstractTrack is created. Track is overwritten as if it did not exist in the first place.
    3. Yes. The hibernate.cfg.xml is NOT updated
    4. Thin. See prior posts. Running into problems connecting with OCI driver.

    This is frustrating. I posted the problem in November. I was asked to wait until M2. Problems are worse now. This is such a disappointment to me as I’ve come to rely on your plugin. I really do not wish to take the time to get accustomed to another plugin like Excadel, but mapping multiple, large Oracle databases, that change almost daily due to new requirements and with xref tables on top of that is too time consuming to simply ignore.

    Look, I can live with the short comings of the Linux distribution. It would be great to have the flow designer to help facilitate the requirements and needs of both the operations and user groups that are driving the applications that I’m building. However, due to the size and frequent changes of the databases I query, a GREAT Hibernate tool is a MUST.

    #244247 Reply

    Daniel Ray
    Member

    Removed eclipse and myeclipse. Reinstalled both. Same problems except that I no longer get a log file to check. All that is present is the version.ini file.

    #244253 Reply

    Riyad Kalla
    Member

    budoray,
    Two of us are working on this thread right now concurrently.

    First I need to appologize for broken stream of help here in this thread, that is my fault for not catching up on the back story before replying and your frustration is absolutely justified. I would also like to thank you for keeping your head and sticking with us while we trouble shoot this with you.

    Now onto the technical details. A developer from the Hib team and I have replicated the Track and TrackType tables in a local install of Oracle using the c reate table statements you provided. We both have 3.1.1 and 4.1M2 installed (as downloaded from the site) and have run through all this thread. We have found the following things and need your help understanding some others. I will use quote blocks below to address things you have posted in this thread thus far and try and number them so we can refer to them later.

    1.

    TRACK has a TRACK_TYPE via the TRACK_TYP_CD and the created mapping is <many-to-one name=”trackType” column=”TRACK_TYP_CD” class=”TrackType” /> which is correct.

    I also get the following mapping for TRACK_TYPE
    <set name=”trackSet” inverse=”true”>
    <key column=”TRACK_TYP_CD”/>
    <one-to-many class=”Track”/>
    </set>

    I do not get this mapping when using MySQL or SQL Server. I am using the classes14.jar. Any advice would be helpful as the DB is still being refined and manually editing the hbm files each time is becoming too time consuming.

    The additional mapping is harmless but correct from the testing we have done. We do not know why this does not occur with MySQL or SQL Server but a huge portion of the mapping generation logic is based off of the JDBC driver being used. That can effect a mapping generation from failing, to getting the wrong type to creating false relationships. There may be something in the oracle driver that reports additional metadata back to the generation logic that ends up creating the inverse of the m2o.

    2.

    Does not generate FK relationships.

    Neither of us could reproduce this. As I mentioned above the m2o and o2m were both created using 4.1M2 from the Oracle tables you gave us above. We also generated ERD diagrams and the relationship was correctly visualized. To make sure, we also generated the DDL for the tables and correctly saw the FK relationship.

    3.

    Subclass is wiped out when new Abstract class is created.

    This is absolutely a bug that will be fixed ASAP. The concrete subclass should not be touched after it’s first generation step.

    4.

    Hibernate.cfg is not getting updated.

    We cannot reproduce this. We tried regenerating the TrackType to a new package, and the hibernate.cfg.xml file was updated with the new hbm.xml record. We also tried genning a new table that hadn’t been mapped before and it was correctly added. Please tell us which steps you took to establish that the update is not being performed.

    #244256 Reply

    Daniel Ray
    Member

    As I mentioned, the db changes very frequently right now. They are regenerating indexes and fk relationships at the moment. I will update this thread the moment I remap.

    #244258 Reply

    Brian Fernandes
    Moderator

    On issue 4 – could you open your project properties and go to the MyEclipse-Hibernate page. Does the “Active configuration file:” point to an existing and valid hibernate configuration file?

    If the configuration file fails to update, an error log will almost certainly be generated. Just in case you are looking in the wrong location, you can go to MyEclipse > About MyEclipse > Configuration Summary and click View Error Log.

    Best,
    Brian.

    #244275 Reply

    snpe
    Member

    i have try read this thread and i think that i know why budoray don’t get ‘set’ mapping when using mysql or ms sql server

    they haven’t define foreign key in this databases

    it is easy check

    have you next when using mysql/ms sql :

    <many-to-one name=”trackType” column=”TRACK_TYP_CD” class=”TrackType” />

    probably , not

    hibernate tools generate many-to-one/one-to-many (foreign keys) relation with <many-to-one> on one side and collection (set) on another side – this is same for every databases – i ask for features taht exclude this in reveng.xml, but it isn’t possible for now

    drivers or database isn’t problem – it is same if you use oci or thin (oci isn’t pure java driver and you have add oracle native client libraries in path for oci)

    and one question for budoray : how big is change in databases that this support is so hard – how many tables,keys and changes
    I think that you can’t find perfect tools for generating mapping from database – this tools have to be general, but
    you have special requests, probably
    I use tool (hibernate tools and myeclipse) for first outline mapping, only and i have to change it alwyas

    #244280 Reply

    Daniel Ray
    Member

    Track table has seven FK. I only get one mapping. The database explorer shows the seven constraints on the FK tab as expected.

    What I’ve found is that I have to select each table referenced as a FK to get the correct mapping.

    #244281 Reply

    Daniel Ray
    Member

    SNPE – Many, many, many tables on multiple databases. This is more like a ‘mining’ operation where one database is built by two others. PKs and FKs are added and removed, tables are dropped, renamed, and more are added as the requirements are further defined. Mapping them by hand is not hard, rather, it’s tedious, time consuming, and prone to more mistakes made by this overworked developer <smile>. The difference with the MySQL and Oracle dbs was the ‘set’ mapping generation that can be ignored since it appears to be driver specific.

    I don’t think I’m asking for anything special. Subclasses shouldn’t be overwritten (thus the AbstractClass generation) and selecting to regenerate a table mapping shouldn’t force me to select each referenced table (Those tables have many FK and those references have FK etc) just to regenerate one table. This was not the case prior to the 4.0 release. (Different engine as explained above).

    #244282 Reply

    Riyad Kalla
    Member

    Subclasses shouldn’t be overwritten (thus the AbstractClass generation)

    This is a bug, we will get it fixed.

    and selecting to regenerate a table mapping shouldn’t force me to select each referenced table (Those tables have many FK and those references have FK etc) just to regenerate one table.

    This wasn’t a use case we tested, while I believe the developer will agree with you I don’t know if the change necessary to make it work the way it should will make it into 4.1. I’ll discuss it with him in a few hours.

    #244283 Reply

    snpe
    Member

    pre 4.0 releases had simple mapping – i can’t use it
    i think that you have to make your templates (.vm files) if you have too much changes in database

    i don’t understand yet whta mean ‘multiple database’ – dou you have different changes in different databases or
    changes propagate to all databases – for former you have to make one mappings for all databases – i can’t think anout first scenario

Viewing 15 posts - 16 through 30 (of 36 total)
Reply To: Hibernate relationships incorrect with Oracle driver

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