-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 posts ] 
Author Message
 Post subject: JDBCBinderException (I *swear* this one's different!)
PostPosted: Thu Jun 01, 2006 11:34 pm 
Newbie

Joined: Thu Jun 01, 2006 11:10 pm
Posts: 4
Location: Southern Maine, USA
I'm a newbie at this... *please* be gentle! I feel stupid enough already! :)

I'm getting the "JDBCBinderException" error, too, but I *think* this is different than the other flavors of this error that I've seen in the forums already. In my case, I'm using Sybase (not Oracle), I've set the default_schema and default_catalog, and I'm excluding unneccessary tables in my reveng.xml with a big-bad "exclude everything" at the end of the file.

I'm generating the *.hbm.xml files using an hbm2hbmxml ant task, and generating the POJOs using an hbm2java task.

Here's some stuff from an example... sorry for all the crap here. I wanted to include enough, hopefully it isn't *too* much...

Hibernate version: 3.2 (tools beta5)

Mapping documents: (Generated by hbm2hbmxml)
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 1, 2006 11:21:30 PM by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="MarketControl" table="MARKET_CONTROL">
<id name="marketId" type="string">
<column name="MarketId" length="5" />
<generator class="assigned" />
</id>
<property name="name" type="string">
<column name="Name" length="20" not-null="true" />
</property>
<property name="depositInterestRate" type="float">
<column name="DepositInterestRate" precision="7" scale="0" not-null="true" />
</property>
<property name="surchargeRate" type="float">
<column name="SurchargeRate" precision="7" scale="0" not-null="true" />
</property>
<property name="paymentDueDay" type="short">
<column name="PaymentDueDay" not-null="true" />
</property>
<property name="defaultRatePlan" type="string">
<column name="DefaultRatePlan" length="8" not-null="true" />
</property>
<property name="lastAccountNumber" type="int">
<column name="LastAccountNumber" not-null="true" />
</property>
<property name="overdueAmt" type="int">
<column name="OverdueAmt" not-null="true" />
</property>
<property name="latePayRate" type="float">
<column name="LatePayRate" precision="7" scale="0" not-null="true" />
</property>
<property name="latePayMinimum" type="int">
<column name="LatePayMinimum" not-null="true" />
</property>
<property name="billCloseDay" type="short">
<column name="BillCloseDay" not-null="true" />
</property>
<property name="nextBillDate" type="timestamp">
<column name="NextBillDate" length="23" not-null="true" />
</property>
<property name="lastPayAdjBatch" type="short">
<column name="LastPayAdjBatch" not-null="true" />
</property>
<property name="lastSvcChgBatch" type="short">
<column name="LastSvcChgBatch" not-null="true" />
</property>
<property name="carryCreditMins" type="char">
<column name="CarryCreditMins" length="1" not-null="true" />
</property>
<property name="callDetail" type="char">
<column name="CallDetail" length="1" not-null="true" />
</property>
<property name="discNotice" type="char">
<column name="DiscNotice" length="1" not-null="true" />
</property>
<property name="voiceMailDep" type="char">
<column name="VoiceMailDep" length="1" not-null="true" />
</property>
<property name="voiceMailRet" type="char">
<column name="VoiceMailRet" length="1" not-null="true" />
</property>
<property name="unansweredCalls" type="char">
<column name="UnansweredCalls" length="1" not-null="true" />
</property>
<property name="ringTimeDuration" type="short">
<column name="RingTimeDuration" not-null="true" />
</property>
<property name="creditMinsExtHome" type="char">
<column name="CreditMinsExtHome" length="1" not-null="true" />
</property>
<property name="switchInterface" type="char">
<column name="SwitchInterface" length="1" not-null="true" />
</property>
<property name="callDelivery" type="char">
<column name="CallDelivery" length="1" not-null="true" />
</property>
<property name="peakStartTime" type="short">
<column name="PeakStartTime" not-null="true" />
</property>
<property name="peakStopTime" type="short">
<column name="PeakStopTime" not-null="true" />
</property>
<property name="offStartTime" type="short">
<column name="OffStartTime" not-null="true" />
</property>
<property name="offStopTime" type="short">
<column name="OffStopTime" not-null="true" />
</property>
<property name="off2startTime" type="short">
<column name="Off2StartTime" not-null="true" />
</property>
<property name="off2stopTime" type="short">
<column name="Off2StopTime" not-null="true" />
</property>
<property name="foreignPeakRate" type="java.lang.Integer">
<column name="ForeignPeakRate" />
</property>
<property name="foreignOffRate" type="java.lang.Integer">
<column name="ForeignOffRate" />
</property>
<property name="foreignOff2rate" type="java.lang.Integer">
<column name="ForeignOff2Rate" />
</property>
<property name="dailyChg" type="int">
<column name="DailyChg" not-null="true" />
</property>
<property name="dateLastCallHome" type="timestamp">
<column name="DateLastCallHome" length="23" />
</property>
<property name="dateLastCallRoam" type="timestamp">
<column name="DateLastCallRoam" length="23" />
</property>
<property name="voiceMailTrunk" type="string">
<column name="VoiceMailTrunk" length="3" />
</property>
<property name="creditCheck" type="java.lang.Character">
<column name="CreditCheck" length="1" />
</property>
<property name="prepayThreshhold" type="java.lang.Integer">
<column name="PrepayThreshhold" />
</property>
<property name="suspSvcChgTdnp" type="java.lang.Character">
<column name="SuspSvcChgTdnp" length="1" />
</property>
<property name="switchTranOnSusp" type="java.lang.Character">
<column name="SwitchTranOnSusp" length="1" />
</property>
<property name="weekendStartDay" type="java.lang.Short">
<column name="WeekendStartDay" />
</property>
<property name="weekendStartTime" type="java.lang.Short">
<column name="WeekendStartTime" />
</property>
<property name="weekendEndDay" type="java.lang.Short">
<column name="WeekendEndDay" />
</property>
<property name="weekendEndTime" type="java.lang.Short">
<column name="WeekendEndTime" />
</property>
<property name="weekendRatePer" type="java.lang.Character">
<column name="WeekendRatePer" length="1" />
</property>
<property name="printCsa" type="java.lang.Character">
<column name="PrintCSA" length="1" />
</property>
<property name="pagerInterface" type="java.lang.Character">
<column name="PagerInterface" length="1" />
</property>
<property name="vmailInterface" type="java.lang.Character">
<column name="VMailInterface" length="1" />
</property>
<property name="internetInterface" type="java.lang.Character">
<column name="InternetInterface" length="1" />
</property>
<property name="newAcctNoteType" type="string">
<column name="NewAcctNoteType" length="5" />
</property>
<property name="newAcctNoteDays" type="java.lang.Short">
<column name="NewAcctNoteDays" />
</property>
<property name="rerateIncollectTaxes" type="java.lang.Character">
<column name="RerateIncollectTaxes" length="1" />
</property>
<property name="lateChgOnTdnp" type="java.lang.Character">
<column name="LateChgOnTDNP" length="1" />
</property>
<property name="assignBillCloseDay" type="java.lang.Character">
<column name="AssignBillCloseDay" length="1" />
</property>
<property name="ccauthPos" type="java.lang.Character">
<column name="CCAuthPOS" length="1" />
</property>
<property name="ccauthCs" type="java.lang.Character">
<column name="CCAuthCS" length="1" />
</property>
<property name="accrueDepositInterest" type="java.lang.Character">
<column name="AccrueDepositInterest" length="1" />
</property>
<property name="defaultNoteType" type="string">
<column name="DefaultNoteType" length="4" />
</property>
<property name="timeZone" type="string">
<column name="TimeZone" length="2" />
</property>
<property name="daylightSavingInd" type="java.lang.Character">
<column name="DaylightSavingInd" length="1" />
</property>
<property name="currencyType" type="string">
<column name="CurrencyType" length="2" />
</property>
<property name="portIn" type="java.lang.Character">
<column name="PortIn" length="1" />
</property>
<property name="portOut" type="java.lang.Character">
<column name="PortOut" length="1" />
</property>
<property name="iccprocess" type="java.lang.Character">
<column name="ICCProcess" length="1" />
</property>
<property name="soaprocess" type="java.lang.Character">
<column name="SOAProcess" length="1" />
</property>
<property name="dataDetail" type="java.lang.Character">
<column name="DataDetail" length="1" />
</property>
<property name="defaultDataPlan" type="string">
<column name="DefaultDataPlan" length="8" />
</property>
<property name="msgDetail" type="java.lang.Character">
<column name="MsgDetail" length="1" />
</property>
<property name="defaultMsgPlan" type="string">
<column name="DefaultMsgPlan" length="8" />
</property>
<property name="otainterface" type="java.lang.Character">
<column name="OTAInterface" length="1" />
</property>
<property name="defaultMediaPlan" type="string">
<column name="DefaultMediaPlan" length="8" not-null="true" />
</property>
<set name="accountMasters" inverse="true">
<key>
<column name="MarketId" length="5" not-null="true" />
</key>
<one-to-many class="AccountMaster" />
</set>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
n/a

Full stack trace of any exception that occurs:
[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.cfg.JDBCBinderException: org.hibernate.mapping.Column(MarketId) already exists in MARKET_CONTROL

BUILD FAILED
D:\_Work\voyager-bos-api\webservice_tests\build.xml:220: org.hibernate.cfg.JDBCBinderException: org.hibernate.mapping.Column(MarketId) already exists in MARKET_CONTROL
at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:194)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:163)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
Caused by: org.hibernate.cfg.JDBCBinderException: org.hibernate.mapping.Column(MarketId) already exists in MARKET_CONTROL
at org.hibernate.cfg.reveng.JDBCReader.processBasicColumns(JDBCReader.java:547)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:79)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:781)
at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:115)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:87)
at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:76)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:226)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:242)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
at org.hibernate.tool.ant.Hbm2JavaExporterTask.configureExporter(Hbm2JavaExporterTask.java:34)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:160)
... 11 more
--- Nested Exception ---
org.hibernate.cfg.JDBCBinderException: org.hibernate.mapping.Column(MarketId) already exists in MARKET_CONTROL
at org.hibernate.cfg.reveng.JDBCReader.processBasicColumns(JDBCReader.java:547)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:79)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:781)
at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:115)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:87)
at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:76)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:226)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:242)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
at org.hibernate.tool.ant.Hbm2JavaExporterTask.configureExporter(Hbm2JavaExporterTask.java:34)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:160)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

Total time: 8 seconds


Name and version of the database you are using:
Sybase ASE 12.5.3 (jConnect 6.0 JDBC driver)

The generated SQL (show_sql=true):
n/a

Debug level Hibernate log excerpt:
n/a


==============================================
Here's my hibernate.reveng.xml file. Note that the MARKET_CONTROL table is the only one left uncommented:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering
SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
<!--
<table-filter match-name="ACCOUNT_MASTER" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>

<table-filter match-name="ACCOUNT_CREDITCARD" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>


<table-filter match-name="ACCOUNT_SALES" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>

<table-filter match-name="AR_CODES" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="AR_HISTORY" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="CONFIG_PARAMS" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="COVERAGE_MAP_1" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="CREDIT_CHECK" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="CREDIT_CHECK_DONE" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="CUSTOMER_TYPE" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="CUSTOMER_ACTIVITY_LOG"
match-catalog="VACLdb" match-schema="dbo">
</table-filter>
<table-filter match-name="DEALER" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="DEVICE_JOURNAL" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="EQUIP_INVENTORY" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>

-->

<table-filter match-name="MARKET_CONTROL" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>

<!--

<table-filter match-name="MEDIA_TABLE" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="MOBILE_FEATURE" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="MOBILE_PHONE" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="MOBILE_PHONE_JOURNAL"
match-catalog="VACLdb" match-schema="dbo">
</table-filter>
<table-filter match-name="MOBILE_PRODUCT" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>

<table-filter match-name="MOBILE_SALES" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>

<table-filter match-name="MSID_MDN_CHANGES" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="POSTAL_CODE_TO_NXX_1"
match-catalog="VACLdb" match-schema="dbo">
</table-filter>
<table-filter match-name="PPW_REPLENISH_AMOUNTS"
match-catalog="VACLdb" match-schema="dbo">
</table-filter>
<table-filter match-name="PRODUCT_CATALOG" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="PRODUCT_VENDOR" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="PROVISIONING_JOURNAL"
match-catalog="VACLdb" match-schema="dbo">
</table-filter>
<table-filter match-name="REPLENISH_DESCRIPTOR"
match-catalog="VACLdb" match-schema="dbo">
</table-filter>
<table-filter match-name="SERVICE_CHARGES" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="SERVICE_PACKAGE" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="SERVICE_PKG_DETAIL" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="SERVICE_PKG_FEATURE"
match-catalog="VACLdb" match-schema="dbo">
</table-filter>
<table-filter match-name="SERVICE_PKG_PRODUCT"
match-catalog="VACLdb" match-schema="dbo">
</table-filter>
<table-filter match-name="SHIPMENT" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>
<table-filter match-name="SO_HISTORY" match-catalog="VACLdb"
match-schema="dbo">
</table-filter>

-->

<table-filter match-name=".*" match-catalog=".*" match-schema=".*" exclude="true" />


</hibernate-reverse-engineering>


And my hibernate.properties (note the default_schema and default_catalog are specified here):


hibernate.connection.driver_class = com.sybase.jdbc3.jdbc.SybDriver
hibernate.connection.url = jdbc:sybase:Tds:XX.XX.XX.XX:XXXX/VACLdb
hibernate.connection.username = XXXXXXXX
hibernate.connection.password =XXXXXXXX
hibernate.connection.pool_size = 5
hibernate.connection.autocommit = true
#hibernate.c3p0.min_size=5
#hibernate.c3p0.max_size=20
#hibernate.c3p0.timeout=1800
#hibernate.c3p0.max_statements=50
hibernate.dialect = org.hibernate.dialect.SybaseDialect
hibernate.default_schema=dbo
hibernate.default_catalog=VACLdb


And (finally!) my ant tasks:

<!-- Generate the java code for all mapping files in our source tree -->
<hibernatetool destdir="${basedir}">
<jdbcconfiguration
propertyfile="${basedir}/config/hibernate/hibernate.properties"
revengfile="${basedir}/config/hibernate/hibernate.reveng.xml"
packagename="test.net.bcgi.voyager.tables">
<fileset dir="${basedir}/test/net/bcgi/voyager/tables">
<include name="MarketControl.hbm.xml"/>
</fileset>
</jdbcconfiguration>
<hbm2java jdk5="false" ejb3="false"/>
</hibernatetool>
</target>

<target name = "hbm2hbmxml">
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="build.classpath"/>

<!-- Generate the java code for all mapping files in our source tree -->
<hibernatetool destdir="${basedir}/test/net/bcgi/voyager/tables">
<jdbcconfiguration propertyfile="${basedir}/config/hibernate/hibernate.properties"
revengfile="${basedir}/config/hibernate/hibernate.reveng.xml"/>
<hbm2hbmxml/>
</hibernatetool>
</target>


===============================================

I can add in the DDL for the MARKET_CONTROL table, too, if you need it.

Any ideas? I'm stumped. :( I've tried manually overriding some things in the reveng file (e.g., create a table name="MARKET_CONTROL", and specify things like the primary key directly), but that doesn't seem to help.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 02, 2006 1:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The mapping file shows your using marketid as the primary key and marketcontrol as fkey for a set mapping to AccountMaster. I agree it should not die like this and have a decent error message but the cause could be that AccountMaster is not included in the tables to process.

Try adding/enabling it in the reveng. If this can be confirmed then JIRA entry should be created so that if the target in the association is not in the list of allowed tables just the property alone should be generated (in this case only the primary key mapping).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 02, 2006 1:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i think the issue is that you are using jdbcconfiguration + also includes and already existing mapping of that class and thus confuses hibernate.

Why do you have that fileset in there under <jdbcconfiguration> ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 02, 2006 6:52 am 
Newbie

Joined: Thu Jun 01, 2006 11:10 pm
Posts: 4
Location: Southern Maine, USA
max wrote:
i think the issue is that you are using jdbcconfiguration + also includes and already existing mapping of that class and thus confuses hibernate.

Why do you have that fileset in there under <jdbcconfiguration> ?


Max - yup, I think you nailed it. I switched my hbm2java task back to using a plain old <configuration> instead of a <jdbcconfiguration>, and it seems to be happy again. I don't remember why I did that... must've been something I tried while I was thrashing helplessly to fix a separate problem (below):

Our database schema kinda sucks, and we have FK's which refer to other tables with compound PK's, and the FK constraints don't contain the entire PK, which causes this:

[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.MappingException: Foreign key (FKD0F44C3AEAE30A85:ACCOUNT_SALES [AccountNumber])) must have same number of columns as the referenced primary key (ACCOUNT_MASTER [MarketId,AccountNumber])

I know this isn't really hibernate's fault, though... I think it's just that the person designing our schema is a nutcase. :)

Is there a way to turn off the attempts at foreign key mapping for these two tables? I tried throwing this at the reveng.xml file, 'cuz I *think* this is what the documentation says I should do:

<table name="ACCOUNT_SALES">
<foreign-key constraint-name="FKD0F44C3AEAE30A85:ACCOUNT_SALES">
<many-to-one property="accountMaster" exclude="true"/>
</foreign-key>
</table>

<table name="ACCOUNT_MASTER">
<foreign-key constraint-name="FKD0F44C3AEAE30A85:ACCOUNT_SALES">
<set property="accountSaleses" exclude="true"/>
</foreign-key>
</table>

but it doesn't seem to affect the output to either AccountMaster.hbm.xml or AccountSales.hbm.xml ... AccountMaster.hbm.xml still contains:

<set name="accountSaleses" inverse="true">
<key>
<column name="AccountNumber" not-null="true" unique="true" />
</key>
<one-to-many class="AccountSales" />
</set>

and AccountSales.hbm.xml still contains:

<many-to-one name="accountMaster" class="AccountMaster" update="false" insert="false" fetch="select">
<column name="AccountNumber" not-null="true" unique="true" />
</many-to-one>

I'm assuming that I haven't defined the table overrides in my reveng.xml file correctly??

Thanks for all of your help... I know it's dififcult to diagnose other people's stuff. Frankly, I'm amazed that you were able to see my mistake earlier so quickly! :)


Top
 Profile  
 
 Post subject: Nevermind. Pilot error.
PostPosted: Fri Jun 02, 2006 7:14 am 
Newbie

Joined: Thu Jun 01, 2006 11:10 pm
Posts: 4
Location: Southern Maine, USA
Quote:
<table name="ACCOUNT_SALES">
<foreign-key constraint-name="FKD0F44C3AEAE30A85:ACCOUNT_SALES">
<many-to-one property="accountMaster" exclude="true"/>
</foreign-key>
</table>

<table name="ACCOUNT_MASTER">
<foreign-key constraint-name="FKD0F44C3AEAE30A85:ACCOUNT_SALES">
<set property="accountSaleses" exclude="true"/>
</foreign-key>
</table>


I was using the made-up name for the FK constraint instead of Sybase's "real" schema metadata name. Changed it to this and all is hunkey dorey...

<table name="ACCOUNT_SALES">
<foreign-key constraint-name="FK_ACCOUNT_SALES_AccountNumber">
<many-to-one property="accountMaster" exclude="true"/>
</foreign-key>
</table>

<table name="ACCOUNT_MASTER">
<foreign-key constraint-name="FK_ACCOUNT_SALES_AccountNumber">
<set property="accountSaleses" exclude="true"/>
</foreign-key>
</table>

Thanks again for all you help!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 02, 2006 8:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
glad you solved your problem.

Could you post a minimal(?) schema that shows your "nutcase situation" ? We should at least be able to read it into the model instead of failing on it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 05, 2006 9:39 am 
Newbie

Joined: Thu Jun 01, 2006 11:10 pm
Posts: 4
Location: Southern Maine, USA
max wrote:
glad you solved your problem.

Could you post a minimal(?) schema that shows your "nutcase situation" ? We should at least be able to read it into the model instead of failing on it.


Actually, I searched through JIRA, and it seems that the issue to which I'm referring has already been mentioned in HBX-620 (http://opensource.atlassian.com/project ... se/HBX-620). Our situation looks like this, but I think it's virtually identical to the issue that was raised already:

Code:
CREATE TABLE dbo.ACCOUNT_MASTER
(
    MarketId              char(5)     NOT NULL,
    AccountNumber         int         NOT NULL,
    BillCloseDay          smallint    NOT NULL,
    CONSTRAINT PK_Mkt_Acct  PRIMARY KEY CLUSTERED (MarketId,AccountNumber)
)

CREATE TABLE dbo.ACCOUNT_SALES
(
    AccountNumber int      NOT NULL,
    SalesId       char(10) NOT NULL,
    CONSTRAINT PK_ACCOUNT_SALES_AccountNumber PRIMARY KEY CLUSTERED (AccountNumber),
    CONSTRAINT FK_ACCOUNT_SALES_AccountNumber FOREIGN KEY (AccountNumber) REFERENCES dbo.ACCOUNT_MASTER (AccountNumber)
)



IMHO, I think it's generally a bad idea to setup situations like this, where the FK on ACCOUNT_SALES refers to part of a compound PK on ACCOUNT_MASTER, which is why I called it a "nutcase" situation. Perhaps it oughtta work anyway, but I wouldn't make it a top priority 'cuz the schema is so ugly. ;)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 05, 2006 9:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i'm not planning on supporting it, just want to make it not fail ;)

put a link on the jira then we can keep this forum and that bug connected.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Reverse engineering, ant, hibernatetools, toString - example
PostPosted: Thu Jun 22, 2006 12:14 pm 
Newbie

Joined: Mon Oct 17, 2005 11:56 am
Posts: 16
Location: Arlington, VA
In a previous post in this forum, "mdesjardins" notes that he switched his jdbcconfiguration back to a plain configuration in his ant build. It's also noted in a earlier post that, to use customized hbm templates, we have to separate the hibernatetools taskdef into 2 separate steps - one for hbm2hbmxml, and a second for hbm2java that USES the output hbm.xml files of the first.

It still took me hours to get this to work due to a couple of "missing-links" in the descriptions. Hope this message helps others get over the hump.

Here is a working ant file that brings the output of hbm2hbmxml into the input of hbm2java. This shows one way to do it. Of course, there is probably a better way, and I'd love to hear it!

Code:
<project name="xxx.hibernate-tools" default="build-all" basedir=".">   

    <target name="build-all" />
   
    <property name="hibtoolsJarDir" value="../../external-tools/hibernate-tools-3.1.0.beta5" />
   
    <path id="toolslib">
        <path location="${hibtoolsJarDir}/asm.jar" />
        <path location="${hibtoolsJarDir}/asm-attrs.jar" />
        <path location="${hibtoolsJarDir}/cglib-2.1.3.jar" />
        <path location="${hibtoolsJarDir}/commons-collections-2.1.1.jar" />
        <path location="${hibtoolsJarDir}/commons-logging-1.0.4.jar" />
        <path location="${hibtoolsJarDir}/dom4j-1.6.1.jar" />
        <path location="${hibtoolsJarDir}/ehcache-1.1.jar" />
        <path location="${hibtoolsJarDir}/freemarker.jar" />
        <path location="${hibtoolsJarDir}/hibernate-tools.jar" />
        <path location="${hibtoolsJarDir}/hibernate3.jar" />
        <path location="${hibtoolsJarDir}/jtidy-r8-21122004.jar" />
        <path location="../../external-tools/oracle/10.2.0/lib/ojdbc14.jar" />
        <path location="resources/hbm" />
    </path>
   
    <taskdef name="hibernatetool1"
         classname="org.hibernate.tool.ant.HibernateToolTask"
         classpathref="toolslib" />
         
    <taskdef name="hibernatetool2"
         classname="org.hibernate.tool.ant.HibernateToolTask"
         classpathref="toolslib" />
         
    <hibernatetool1>
       <jdbcconfiguration
           packagename="com.xxx.common.security.model"
            configurationfile="./hibernate.cfg.xml"
            revengfile="./hibernate.reveng.xml" >           
        </jdbcconfiguration>
        <hbm2hbmxml destdir="resources/hbm" templatepath="hibernate-tools-templates"/>
    </hibernatetool1>
   
    <hibernatetool2>
        <!-- Include files generated by hbm2hbmxml as input to hbm2java -->
       <configuration>
            <fileset dir="resources/hbm" >
                <include name="**/security/model/*.hbm.xml"/>
                <include name="**/cc/model/Claim.hbm.xml"/>
                <include name="**/cc/model/ClaimContact.hbm.xml"/>
                <include name="**/cc/model/ClaimDetail.hbm.xml"/>
                <include name="**/cc/model/ClaimDetailItem.hbm.xml"/>
                <include name="**/cc/model/ClaimReason.hbm.xml"/>
                <include name="**/cc/model/Contact.hbm.xml"/>
                <exclude name="**/workflow"/>
            </fileset>
        </configuration>   
        <hbm2java destdir="src/generated" jdk5="true" ejb3="false" templatepath="hibernate-tools-templates"/>
    </hibernatetool2>

</project>


Since the switch from velocity to freemarker, some of the old template customization comments in the forum are out of date. To get a meta tag for "toString" into your hbm.xml and thus into your java, you need to extract freemarker template files from the hibernatetools.jar file, modify them, and place them in a sub-folder in your project with the same folder name as the original, i.e., hbm, pojo, etc. You also have to add templatepath to your hbm2java task (pointing to the template folder that holds the pojo folder). See example above.

I added meta toString and equals lines to freemarker templates "pojo/pkcolumn.hbm.ftl" and "pojo/property.hbm.ftl". These may not be perfect (pk used in equals currently), but they're a start.

Here is the modified "pkproperty.hbm.ftl"

Code:
   <property
        name="${property.name}"
        type="${property.value.typeName}"
<#if !property.updateable>
        update="false"
</#if>
<#if !property.insertable>
        insert="false"
</#if>
<#if !property.basicPropertyAccessor>
        access="${property.propertyAccessorName}"
</#if>
<#if property.lazy>
        lazy="true"
</#if>
<#if !property.optimisticLocked>
        optimistic-lock="false"
</#if>
<#if property.value.hasFormula()>
<#assign formula = c2h.getFormulaForProperty(property)>
<#if formula?has_content>
        formula="${formula.text}"
</#if>
    />
<#else>
    >
      <meta attribute="use-in-tostring">true</meta>
      <meta attribute="use-in-equals">true</meta>
  <#foreach column in property.columnIterator>
        <#include "column.hbm.ftl">
  </#foreach>   
  </property>
</#if>



Here is the modified "pkcolumn.hbm.ftl"

Code:
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
<column name="${column.quotedName}" ${c2h.columnAttributes(column, true)}/>



Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 1:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
You do know that applying toequals on every property is *bad* ?

I would love to hear what those "missing links" in the docs are and possible remedies for them :)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: PK in "equals()" is bad - got it!
PostPosted: Fri Jun 23, 2006 9:34 am 
Newbie

Joined: Mon Oct 17, 2005 11:56 am
Posts: 16
Location: Arlington, VA
The missing links are more to do with people's emails here, rather than the documentation - specifically mdesjardins saying to split build into 2 steps, one taking the input of the other, but not showing how to do that. My post shows how to do that, though probably not the best way, at least it works! The other being which freemarker templates need to be modified and how for toString and equals.

I noted in my post "These may not be perfect (pk used in equals currently)" - so, yeah, id in equals is bad if detached objects accessed used outside a session before an id is assigned. Don't have that situation in our app, but probably should avoid the possibility anyway. I read the all the previous emails in this topic several times (still didn't follow them!).

Overall, after about a week, I'm finally getting the generation to work pretty much as it had been working in Middlegen on about 20 tables - planning to do more as I go. Two differences between middlegen and hibernatetools that will require code changes in client code are:

1) the name of a composite key class is tableNameId instead of tableNamePK from middlegen.

2) the method to get a composite id is getTableNameId instead of getComp_id from middlegen.

Thanks!


Top
 Profile  
 
 Post subject: Re: JDBCBinderException (I *swear* this one's different!)
PostPosted: Tue Jul 06, 2010 6:16 am 
Newbie

Joined: Tue Jul 06, 2010 6:09 am
Posts: 1
I need to use jdbcconfiguration since I specify the additional properties (packagename, revengfile, and detectmanytomany). The issue is that the moment you specify the fileset of hbm.xml files (I need to add custom code to certain classes) containing meta attributes, the org.hibernate.cfg.JDBCBinderException exception appears with the following stack trace.

I am using HSQL. Not sure if it matters which DB it is.

Is this an issue with jdbcconfiguration? I am using hibernate tools 3.2.4.GA from ant.

Caused by: org.hibernate.cfg.JDBCBinderException: Duplicate class name 'com.gs.fw.legal.big.data.RiskTopic' generated for 'org.hibernate.mapping.Table(BIG.RISK_TOPIC)'. Same name where generated for 'org.hibernate.mapping.Table(BIG.RISK_TOPIC)'
at org.hibernate.cfg.JDBCBinder.createPersistentClasses(JDBCBinder.java:172)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:95)
at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:42)
at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:83)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
at org.hibernate.tool.ant.Hbm2JavaExporterTask.configureExporter(Hbm2JavaExporterTask.java:34)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
... 15 more
--- Nested Exception ---
org.hibernate.cfg.JDBCBinderException: Duplicate class name 'com.gs.fw.legal.big.data.RiskTopic' generated for 'org.hibernate.mapping.Table(BIG.RISK_TOPIC)'. Same name where generated for 'org.hibernate.mapping.Table(BIG.RISK_TOPIC)'
at org.hibernate.cfg.JDBCBinder.createPersistentClasses(JDBCBinder.java:172)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:95)
at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:42)
at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:83)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)


Top
 Profile  
 
 Post subject: Re: JDBCBinderException (I *swear* this one's different!)
PostPosted: Wed Mar 21, 2012 7:44 am 
Newbie

Joined: Wed Mar 21, 2012 7:35 am
Posts: 1
O problema ocorre quando existem dois nomes de fk iguais em tabelas do mesmo schema - basta alterar o nome de uma fk que está repetida e o problema está solucionado.

Inglês (sorry, but my english is poor)
The problem occurs when there are two names fk equal in the same schema tables - just change the name of a fk that is repeated and the problem is solved.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.