Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
budoray
Post subject: Hibernate relationships incorrect with Oracle driver  PostPosted: Nov 07, 2005 - 04:29 PM
Registered Member
Registered Member


Joined: Jan 20, 2004
Posts: 44

Generating Hibernate mappings via DB explorer is creating relationships that do not exist in the Oracle DB. DB has two tables, TRACK and TRACK_TYPE.

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.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
budoray
Post subject:   PostPosted: Nov 07, 2005 - 10:12 PM
Registered Member
Registered Member


Joined: Jan 20, 2004
Posts: 44

Version: 3.1.0
Build id: I20050627-1435
Version: 4.0.1
Build id: 20050930-4.0.1-GA
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-rkalla
Post subject:   PostPosted: Nov 08, 2005 - 01:42 AM
Moderator
Moderator


Joined: Jan 06, 2004
Posts: 23347

1) Please post the C REATE TABLE scripts for the two tables, NOTE you will need to break up the SQL keywords because we have a security plugint hat will stop the posting of the scripts.

2) Where did classes14.jar come from and how are you "using it"?

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
budoray
Post subject:   PostPosted: Nov 09, 2005 - 03:40 PM
Registered Member
Registered Member


Joined: Jan 20, 2004
Posts: 44

Heres the setup in the config file. (elipses used to hide connection info)

<hibernate-configuration>
<session-factory>
<property name="myeclipse.connection.profile">LDSMETA</property>
<property name="connection.url">jdbc:oracle:thin:@...</property>
<property name="connection.username">...</property>
<property name="connection.password">...</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>

Create script for Track table
c-reate table "LDSMETA"."TRACK"(
"TRACK_ID" NUMBER(12) PRIMARY KEY not null,
"TRACK_TYP_CD" CHAR(1),
"TRACK_TITLE" VARCHAR2)

Create script for Track_Type table
c-reate table "LDSMETA"."TRACK_TYPE"(
"TRACK_TYP_CD" CHAR(1) PRIMARY KEY not null,
"TRACK_TYP_DESC" VARCHAR2 not null,
"ACTIVE" CHAR(1) default ''N' ' not null)

I gave the wrong jar name in my haste. The correct jar that contains the Oracle driver is ojdbc14.jar.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-rkalla
Post subject:   PostPosted: Nov 09, 2005 - 04:30 PM
Moderator
Moderator


Joined: Jan 06, 2004
Posts: 23347

I think you may have excluded any of the Foreign Key constraints from your c-reate table scripts, because from what you posted above I'm not sure how you ended up with a m2o or even a set relationship... can you post the entire generated c-reate table script for me? I want to try and reproduce this issue locally.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
budoray
Post subject:   PostPosted: Nov 09, 2005 - 05:55 PM
Registered Member
Registered Member


Joined: Jan 20, 2004
Posts: 44

Well, the script was created using the db tool. Bug in the 'generate table script' option? FK shows up in my .mer file.

Here's the script from the Oracle DBA.
C-REATE TABLE LDSMETA.TRACK
(
TRACK_ID NUMBER(12) NOT NULL,
TRACK_TYP_CD CHAR(1) NULL,
TRACK_TITLE VARCHAR2(256) NULL,
CONSTRAINT TRACK_FK1
FOREIGN KEY (TRACK_TYP_CD)
REFERENCES LDSMETA.TRACK_TYPE (TRACK_TYP_CD)
ENABLE,
)
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-rkalla
Post subject:   PostPosted: Nov 09, 2005 - 06:52 PM
Moderator
Moderator


Joined: Jan 06, 2004
Posts: 23347

Sorry, could you also post the TRACK_TYPE script as well, I'm still not seeing a reason why the hibernate mapper decided to create a set for you, very odd...

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
budoray
Post subject:   PostPosted: Nov 09, 2005 - 07:19 PM
Registered Member
Registered Member


Joined: Jan 20, 2004
Posts: 44

Track Type script is in earlier post. Could the indexes on the tables be causing the problems? I have the same problem for all the tables in the db where one table has a m2o relationship to another and I get a o2m (set) on the 'another' table. Could the driver be the problem? Oracle 10.1.0.4.

C-REATE INDEX LDSMETA.TRACK_IX1
ON LDSMETA.TRACK(TRACK_TYP_CD)
A-LTER TABLE LDSMETA.TRACK
ADD CONSTRAINT TRACK_PK
PRIMARY KEY (TRACK_ID)
ENABLE
VALIDATE

C-REATE INDEX LDSMETA.TRACK_TYPE_PIX
ON LDSMETA.TRACK_TYPE(TRACK_TYP_CD)
A-LTER TABLE LDSMETA.TRACK_TYPE
ADD CONSTRAINT TRACK_TYPE_PK
PRIMARY KEY (TRACK_TYP_CD)
ENABLE
VALIDATE
/
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-rkalla
Post subject:   PostPosted: Nov 09, 2005 - 07:32 PM
Moderator
Moderator


Joined: Jan 06, 2004
Posts: 23347

It is certainly possible that the driver is returning metadata that is causing the mapping generator to create that set. If possible, could you wait a few weeks for our 4.1M2 release and try using the new mapping generator that will be in that version? We are completely replacing it, so I would hate to spend a lot of time analyzing every possible problem here, and then have all of it fixed when 4.1M2 get's released.

Is this a viable option for you for the time being?

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
budoray
Post subject:   PostPosted: Nov 09, 2005 - 07:44 PM
Registered Member
Registered Member


Joined: Jan 20, 2004
Posts: 44

It's frustrating being that I paid for a pro version of the software and haven't really gained anything by doing so. I'll try a few other Oracle drivers in the meantime being that I already have to wait on other features available for Windows that aren't available for Mac and Linux. Again, waiting appears to be the norm now.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-rkalla
Post subject:   PostPosted: Nov 09, 2005 - 08:07 PM
Moderator
Moderator


Joined: Jan 06, 2004
Posts: 23347

Ok so clearly this is not a viable option, I've asked a developer from the Hibernate team to look into this to hopefully find a temporary workaround for you.

Quote:

I'll try a few other Oracle drivers in the meantime being that I already have to wait on other features available for Windows that aren't available for Mac and Linux. Again, waiting appears to be the norm now.

The only feature that is Windows only is the new designer which is in the process of being ported to Mac/Linux. The only features that isn't on the Mac due to an SWT-bug in the Eclipse platform itself is the UML editor.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
budoray
Post subject:   PostPosted: Nov 09, 2005 - 08:49 PM
Registered Member
Registered Member


Joined: Jan 20, 2004
Posts: 44

Upgraded to 4.1m1 ( New Hibernate Mapping Editor and custom Outline View ) and problem persists

<hibernate-mapping package="...">

<class name="Track" table="TRACK">
<id name="trackId" column="TRACK_ID" type="java.lang.Long">
<generator class="increment"/>
</id>

<property name="trackTitle" column="TRACK_TITLE" type="java.lang.String" />

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

</class>

</hibernate-mapping>


<hibernate-mapping package="...">

<class name="TrackType" table="TRACK_TYPE">
<id name="trackTypCd" column="TRACK_TYP_CD" type="java.lang.String">
<generator class="increment"/>
</id>

<property name="trackTypDesc" column="TRACK_TYP_DESC" type="java.lang.String" not-null="true" />
<property name="active" column="ACTIVE" type="java.lang.String" not-null="true" />

<set name="trackSet" inverse="true">
<key column="TRACK_TYP_CD"/>
<one-to-many class="Track"/>
</set>
</class>

</hibernate-mapping>
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
budoray
Post subject:   PostPosted: Nov 09, 2005 - 08:51 PM
Registered Member
Registered Member


Joined: Jan 20, 2004
Posts: 44

Err .. quick genration of tables has TRACK_TYPE with a generator. There is no generator class for TRACK_TYPE.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-rkalla
Post subject:   PostPosted: Nov 10, 2005 - 01:44 AM
Moderator
Moderator


Joined: Jan 06, 2004
Posts: 23347

4.1M1 still includes our old generator, M2 will include the new mapping generator.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
budoray
Post subject:   PostPosted: Nov 10, 2005 - 03:42 PM
Registered Member
Registered Member


Joined: Jan 20, 2004
Posts: 44

Fair enough. I've manually edited the generated files and classes to correctly reflect the db. I had no luck getting the oci driver to work even after installing the Instant Client. For now, I'm going to leave things as they are and refrain from using the db tools within Myeclipse until the M2 release due to the number of tables I'm dealing with. Again, this is one of several db that I will have to work with and being able to quickly generate my hibernate mappings and classes will greatly reduce my overtime. Not to mention the changes needed as each of the db evolve.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits