- This topic has 35 replies, 4 voices, and was last updated 18 years, 9 months ago by Daniel Ray.
-
AuthorPosts
-
Daniel RayMemberGenerating 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.
Daniel RayMemberVersion: 3.1.0
Build id: I20050627-1435
Version: 4.0.1
Build id: 20050930-4.0.1-GA
Riyad KallaMember1) 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”?
Daniel RayMemberHeres 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.
Riyad KallaMemberI 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.
Daniel RayMemberWell, 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,
)
Riyad KallaMemberSorry, 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…
Daniel RayMemberTrack 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
VALIDATEC-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
/
Riyad KallaMemberIt 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?
Daniel RayMemberIt’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.
Riyad KallaMemberOk 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.
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.
Daniel RayMemberUpgraded 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>
Daniel RayMemberErr .. quick genration of tables has TRACK_TYPE with a generator. There is no generator class for TRACK_TYPE.
Riyad KallaMember4.1M1 still includes our old generator, M2 will include the new mapping generator.
Daniel RayMemberFair 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.
-
AuthorPosts