Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1.7
Using Oracle 10g
I'm trying to use middlegen to create mappings from our database schema. I'm using middlegen 2.0 since 2.1 doesn't work with our Oracle 10g database - it keeps complaining about a bad schema - the one we list is in the list that it gives as possible schemas...go figure.
Anyway, I have a table that has three columns in its primary key. Two of those columns come from another table (a foreign key). Middlegen creates a primary key portion or component-like structure for the primary key with those three columns. However when the hbm2java runs, it creates a constructor that only takes two parameters. One is the data field specific to my table. The other parameter is an object where the foreign keyed fields come from. It reports that there is a wrong number of columns - a mapping exception when trying to load the mappings from the hibernate.cfg.xml file. Any help would be greatly appreciated!
Stack trace:
Exception in thread "main" net.sf.hibernate.MappingException: identifier mapping has wrong number of columns: com.mostlyharmless.travel.hibernate.TlAirVendorPref type: com.mostlyharmless.travel.hibernate.TlAirVendorPrefPK
at net.sf.hibernate.mapping.RootClass.validate(RootClass.java:171)
at net.sf.hibernate.cfg.Configuration.validate(Configuration.java:633)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:799)
at com.mostlyharmless.travel.hibernate.util.TravelUtil.getSessionFactory(Unknown Source)
at com.mostlyharmless.travel.hibernate.util.TravelUtil.getSession(Unknown Source)
at com.mostlyharmless.travel.hibernate.HQL_MyAccount.getFees(HQL_MyAccount.java:33)
at com.mostlyharmless.travel.hibernate.HQL_MyAccount.main(HQL_MyAccount.java:75)
Composite-id mapping generated by middlegen:
<composite-id name="comp_id" class="com.mostlyharmless.travel.hibernate.TlAirVendorPrefPK">
<key-property
name="sequenceNumber"
column="SEQUENCE_NUMBER"
type="java.math.BigDecimal"
length="22"
/>
<!-- bi-directional many-to-one association to TlFlightPref -->
<key-many-to-one
name="tlFlightPref"
class="com.mostlyharmless.travel.hibernate.TlFlightPref"
>
<column name="CUSTOMER_ID" />
<column name="TRAVELER_ID" />
</key-many-to-one>
</composite-id>