from EmployerCharges r1 where r1.routingCode.routingCode = ? and employer.employerId=?
where the following are the pojo classes
<class name="com.greytip.wps.model.EmployerCharges" table="emp_RoutingCode_Charges" lazy="false">
<id name="id" type="int" unsaved-value="0" >
<generator class="native">
<param name="sequence">emp_RoutingCode_id_seq</param>
</generator>
</id>
<many-to-one name ="employer" class = "com.greytip.wps.model.Employer"/>
<many-to-one name ="routingCode" class = "com.greytip.wps.model.RoutingCode"/>
<property name="charges"/>
</class>
//----------------------------------------
hibernate-mapping package="com.greytip.wps.model">
<class name="com.greytip.wps.model.Employer" table="wps_employer" lazy="false">
<id name="id" type="int" unsaved-value="0" >
<generator class="native">
<param name="sequence">wps_employer_id_seq</param>
</generator>
</id>
<property name="employerId"/>
<property name="name"/>
<property name="contactPerson"/>
<property name="address"/>
<property name="bankAcNo"/>
<property name="email"/>
<property name="licenseNo"/>
<property name="licenseExpiryDate"/>
<property name="active"/>
<many-to-one name ="emirateCode"/>
<many-to-one name ="economicActivity"/>
<many-to-one name ="wpsQueue"/>
<property name="schemaCreated"/>
<property name="code"/>
<many-to-one name ="branch"/>
<property name="bankCharges"/>
<property name="contactNo"/>
<many-to-one name="relationshipManager"/>
<many-to-one name ="employerGroup"/>
<property name="hpsEmployerReference"></property>
<property name="chargeReprocessing"></property>
<property name="restrictAccess"></property>
<property name="bankChargesPerFile"></property>
<property name="enableSalaryCardRequest"></property>
<property name="salaryCardCharges"/>
<property name="ftsBankChargesPerFile"/>
<property name="ftsIntBankChargesPerRecord"/>
<property name="ftsExtBankChargesPerRecord"/>
<property name="ftsExtBankChargesPerBank"/>
<property name="ftsIntBankChargesPerBank"/>
<property name="signature"/>
<property name="scReissueCharges"></property>
<property name="scActivateCharges"></property>
<property name="scCancelCharges"></property>
<property name="scReIssuePinCharges"></property>
<many-to-one name ="employerWorkflow"/>
<many-to-one name ="employerCategory"/>
<property name="poBox"></property>
<property name="bankChargesPerBank"></property>
<property name="bankChargesPerMonth"></property>
<property name="defaultCharges"></property>
<property name="isDeleted"></property>
<property name="monthlyCharges"></property>
<property name="appliedCharge"></property>
</class>
//-----------------------------------------------
<hibernate-mapping package="com.greytip.wps.model">
<class name="com.greytip.wps.model.RoutingCode" table="wps_routingCode" lazy="false">
<id name="id" type="int" unsaved-value="0" >
<generator class="native">
<param name="sequence">wps_routingCode_id_seq</param>
</generator>
</id>
<property name="bankCode"/>
<property name="bankName"/>
<property name="routingCode"/>
<property name="branchName"/>
</class>
Please tell me how to convert the hql to sql... Thank you..
Enable show sql and format sql parameters in hibernate configuration and you can see the queries being fired in the log file.
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property>
For more information see this question
Related
I have three persistent classes named:shops.class,user.class,vehicle.class and three hibernate mapping file shops.hbm.xml,users.hbm.xml,vehicle.hbm.xml
But i am getting following error in my users and vehicle mappingg file:
The content of element type "class" must match
"(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,fetch-profile*,resultset*,(query|sql-query)*)".
shops.hbm.xml:
<?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 7, 2017 2:04:29 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="persistent_classes.shops" table="SHOPS">
<id name="id" type="int">
<column name="ID" />
<generator class="increment" />
</id>
<version name="version_id" type="int" unsaved-value="undefined">
<column name="VERSION_ID" />
</version>
<property name="name" type="java.lang.String">
<column name="NAME" />
</property>
<property name="address" type="java.lang.String">
<column name="ADDRESS" />
</property>
<property name="city" type="java.lang.String">
<column name="CITY" />
</property>
<property name="dealername" type="java.lang.String">
<column name="DEALERNAME" />
</property>
<property name="dealerno" type="java.lang.String">
<column name="DEALERNO" />
</property>
<property name="dealeremail" type="java.lang.String">
<column name="DEALEREMAIL" />
</property>
<property name="password" type="java.lang.String">
<column name="PASSWORD" />
</property>
<property name="shops_string" type="java.lang.String">
<column name="SHOPS_STRING" />
</property>
<property name="login" type="boolean">
<column name="LOGIN" />
</property>
<list name="vehicles" inverse="false" table="VEHICLE" lazy="true">
<key>
<column name="store_id" />
</key>
<list-index></list-index>
<one-to-many class="persistent_classes.vehicle" />
</list>
<map name="users" table="SHOPS_MAP" lazy="true">
<key>
<column name="ID" />
</key>
<map-key type="java.lang.Integer"></map-key>
<element type="java.lang.Integer">
<column name="USERS" />
</element>
</map>
</class>
</hibernate-mapping>
vehicle.hbm.xml:
<?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 7, 2017 2:04:29 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="persistent_classes.vehicle" table="VEHICLE">
<id name="id" type="int">
<column name="ID" />
<generator class="increment" />
</id>
<property name="stock" type="int">
<column name="STOCK" />
</property>
<version name="version_id" type="int" unsaved-value="undefined">
<column name="VERSION_ID" />
</version>
<property name="name" type="java.lang.String">
<column name="NAME" />
</property>
<property name="company" type="java.lang.String">
<column name="COMPANY" />
</property>
<property name="milage" type="java.lang.String">
<column name="MILAGE" />
</property>
<property name="year" type="java.lang.String">
<column name="YEAR" />
</property>
<property name="priceoriginal" type="java.lang.String">
<column name="PRICEORIGINAL" />
</property>
<property name="priceoffer" type="java.lang.String">
<column name="PRICEOFFER" />
</property>
<property name="vehicle_string" type="java.lang.String">
<column name="VEHICLE_STRING" />
</property>
</class>
</hibernate-mapping>
users.hbm.xml:
<?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 7, 2017 2:04:40 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="persistent_classes.users" table="USERS">
<id name="id" type="int">
<column name="ID" />
<generator class="increment" />
</id>
<map name="points" table="user_points" cascade="all">
<key column="user_id" />
<index column="shop_id" type="integer"></index>
<element column="points" type="string"></element>
</map>
<version name="version_id" type="int" unsaved-value="undefined">
<column name="VERSION_ID" />
</version>
<property name="login" type="boolean">
<column name="LOGIN" />
</property>
<property name="name" type="java.lang.String">
<column name="NAME" />
</property>
<property name="password" type="java.lang.String">
<column name="PASSWORD" />
</property>
<property name="email" type="java.lang.String">
<column name="EMAIL" />
</property>
<property name="mobno" type="java.lang.String">
<column name="MOBNO" />
</property>
<property name="address" type="java.lang.String">
<column name="ADDRESS" />
</property>
<property name="users_string" type="java.lang.String">
<column name="USERS_STRING" />
</property>
</class>
</hibernate-mapping>
I know this question is asked many times but all of that were related to not using tag. But i had used this tag in all files but still getting this error in users and vehicle file.
Please Help i am badly stuck with this.
Thanks in advance
version must be defined before property and map
Move it to be right after id definition in the users and vehicle hbm
In my PostgreSQL ERP database, I have a table "Custtable", which has a composite primary key, made from the following fields:
accountnum (String)
partition (Long)
dataareaid (String)
As I understand, because of this composite key, I have to implement a separat POJO, which will serve as the ID field for my "Custtable" hibernate class:
public class CusttableId {
private String accountnum;
private Long partition;
private String dataareaid;
public CusttableId(){
}
public String getAccountnum(){
return accountnum;
}
public void setAccountnum( String an ) {
accountnum = an;
}
public Long getPartition(){
return partition;
}
public void setPartition(Long part){
partition = part;
}
Then, I can use this ID class in my main class:
#Entity
public class Custtable implements java.io.Serializable {
#Id
private CusttableId custTableId;
Having done that, when I use Eclipse Hibernate Tools menu to generate the .hbn.xml mapping file for my main class, I get the following mapping:
<?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 Sep 7, 2016 10:15:45 AM by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
<class name="com.myproject.Custtable" table="CUSTTABLE">
<id name="orgid" type="java.lang.String">
<column name="ORGID" />
<generator class="assigned" />
</id>
<many-to-one name="custTableId" class="com.uptake.symphony.data.CusttableId" access="field" fetch="join">
<column name="CUSTTABLEID" />
</many-to-one>
<property name="invoiceaccount" type="java.lang.String">
<column name="INVOICEACCOUNT" />
</property>
<property name="custgroup" type="java.lang.String">
<column name="CUSTGROUP" />
</property>
<property name="linedisc" type="java.lang.String">
<column name="LINEDISC" />
</property>
<property name="paymtermid" type="java.lang.String">
<column name="PAYMTERMID" />
</property>
<property name="cashdisc" type="java.lang.String">
<column name="CASHDISC" />
</property>
<property name="currency" type="java.lang.String">
<column name="CURRENCY" />
</property>
<property name="intercompanyautocreateorders" type="int">
<column name="INTERCOMPANYAUTOCREATEORDERS" />
</property>
<property name="salesgroup" type="java.lang.String">
<column name="SALESGROUP" />
</property>
<property name="blocked" type="int">
<column name="BLOCKED" />
</property>
<property name="onetimecustomer" type="int">
<column name="ONETIMECUSTOMER" />
</property>
<property name="accountstatement" type="int">
<column name="ACCOUNTSTATEMENT" />
</property>
<property name="creditmax" type="java.math.BigDecimal">
<column name="CREDITMAX" />
</property>
<property name="mandatorycreditlimit" type="int">
<column name="MANDATORYCREDITLIMIT" />
</property>
<property name="vendaccount" type="java.lang.String">
<column name="VENDACCOUNT" />
</property>
<property name="pricegroup" type="java.lang.String">
<column name="PRICEGROUP" />
</property>
<property name="multilinedisc" type="java.lang.String">
<column name="MULTILINEDISC" />
</property>
<property name="enddisc" type="java.lang.String">
<column name="ENDDISC" />
</property>
<property name="vatnum" type="java.lang.String">
<column name="VATNUM" />
</property>
<property name="inventlocation" type="java.lang.String">
<column name="INVENTLOCATION" />
</property>
<property name="dlvterm" type="java.lang.String">
<column name="DLVTERM" />
</property>
<property name="dlvmode" type="java.lang.String">
<column name="DLVMODE" />
</property>
<property name="markupgroup" type="java.lang.String">
<column name="MARKUPGROUP" />
</property>
<property name="clearingperiod" type="java.lang.String">
<column name="CLEARINGPERIOD" />
</property>
<property name="freightzone" type="java.lang.String">
<column name="FREIGHTZONE" />
</property>
<property name="creditrating" type="java.lang.String">
<column name="CREDITRATING" />
</property>
<property name="taxgroup" type="java.lang.String">
<column name="TAXGROUP" />
</property>
<property name="statisticsgroup" type="java.lang.String">
<column name="STATISTICSGROUP" />
</property>
<property name="paymmode" type="java.lang.String">
<column name="PAYMMODE" />
</property>
<property name="commissiongroup" type="java.lang.String">
<column name="COMMISSIONGROUP" />
</property>
<property name="bankaccount" type="java.lang.String">
<column name="BANKACCOUNT" />
</property>
<property name="paymsched" type="java.lang.String">
<column name="PAYMSCHED" />
</property>
<property name="contactpersonid" type="java.lang.String">
<column name="CONTACTPERSONID" />
</property>
<property name="invoiceaddress" type="int">
<column name="INVOICEADDRESS" />
</property>
<property name="ouraccountnum" type="java.lang.String">
<column name="OURACCOUNTNUM" />
</property>
<property name="salespoolid" type="java.lang.String">
<column name="SALESPOOLID" />
</property>
<property name="incltax" type="int">
<column name="INCLTAX" />
</property>
<property name="custitemgroupid" type="java.lang.String">
<column name="CUSTITEMGROUPID" />
</property>
<property name="numbersequencegroup" type="java.lang.String">
<column name="NUMBERSEQUENCEGROUP" />
</property>
<property name="paymdayid" type="java.lang.String">
<column name="PAYMDAYID" />
</property>
<property name="lineofbusinessid" type="java.lang.String">
<column name="LINEOFBUSINESSID" />
</property>
<property name="destinationcodeid" type="java.lang.String">
<column name="DESTINATIONCODEID" />
</property>
<property name="girotype" type="int">
<column name="GIROTYPE" />
</property>
<property name="suppitemgroupid" type="java.lang.String">
<column name="SUPPITEMGROUPID" />
</property>
<property name="girotypeinterestnote" type="int">
<column name="GIROTYPEINTERESTNOTE" />
</property>
<property name="taxlicensenum" type="java.lang.String">
<column name="TAXLICENSENUM" />
</property>
<property name="websalesorderdisplay" type="int">
<column name="WEBSALESORDERDISPLAY" />
</property>
<property name="paymspec" type="java.lang.String">
<column name="PAYMSPEC" />
</property>
<property name="bankcentralbankpurposetext" type="java.lang.String">
<column name="BANKCENTRALBANKPURPOSETEXT" />
</property>
<property name="bankcentralbankpurposecode" type="java.lang.String">
<column name="BANKCENTRALBANKPURPOSECODE" />
</property>
<property name="intercompanyallowindirectcreation" type="int">
<column name="INTERCOMPANYALLOWINDIRECTCREATION" />
</property>
<property name="packmaterialfeelicensenum" type="java.lang.String">
<column name="PACKMATERIALFEELICENSENUM" />
</property>
<property name="taxbordernumberFi" type="java.lang.String">
<column name="TAXBORDERNUMBERFI" />
</property>
<property name="einvoiceeannum" type="java.lang.String">
<column name="EINVOICEEANNUM" />
</property>
<property name="fiscalcode" type="java.lang.String">
<column name="FISCALCODE" />
</property>
<property name="dlvreason" type="java.lang.String">
<column name="DLVREASON" />
</property>
<property name="forecastdmpinclude" type="int">
<column name="FORECASTDMPINCLUDE" />
</property>
<property name="girotypecollectionletter" type="int">
<column name="GIROTYPECOLLECTIONLETTER" />
</property>
<property name="salescalendarid" type="java.lang.String">
<column name="SALESCALENDARID" />
</property>
<property name="custclassificationid" type="java.lang.String">
<column name="CUSTCLASSIFICATIONID" />
</property>
<property name="intercompanydirectdelivery" type="int">
<column name="INTERCOMPANYDIRECTDELIVERY" />
</property>
<property name="enterprisenumber" type="java.lang.String">
<column name="ENTERPRISENUMBER" />
</property>
<property name="shipcarrieraccount" type="java.lang.String">
<column name="SHIPCARRIERACCOUNT" />
</property>
<property name="girotypeprojinvoice" type="int">
<column name="GIROTYPEPROJINVOICE" />
</property>
<property name="inventsiteid" type="java.lang.String">
<column name="INVENTSITEID" />
</property>
<property name="orderentrydeadlinegroupid" type="java.lang.String">
<column name="ORDERENTRYDEADLINEGROUPID" />
</property>
<property name="shipcarrierid" type="java.lang.String">
<column name="SHIPCARRIERID" />
</property>
<property name="shipcarrierfuelsurcharge" type="int">
<column name="SHIPCARRIERFUELSURCHARGE" />
</property>
<property name="shipcarrierblindshipment" type="int">
<column name="SHIPCARRIERBLINDSHIPMENT" />
</property>
<property name="shipcarrieraccountcode" type="java.lang.String">
<column name="SHIPCARRIERACCOUNTCODE" />
</property>
<property name="girotypefreetextinvoice" type="int">
<column name="GIROTYPEFREETEXTINVOICE" />
</property>
<property name="syncentityid" type="java.lang.String">
<column name="SYNCENTITYID" />
</property>
<property name="syncversion" type="long">
<column name="SYNCVERSION" />
</property>
<property name="memo" type="java.lang.String">
<column name="MEMO" />
</property>
<property name="salesdistrictid" type="java.lang.String">
<column name="SALESDISTRICTID" />
</property>
<property name="segmentid" type="java.lang.String">
<column name="SEGMENTID" />
</property>
<property name="subsegmentid" type="java.lang.String">
<column name="SUBSEGMENTID" />
</property>
<property name="rfiditemtagging" type="int">
<column name="RFIDITEMTAGGING" />
</property>
<property name="rfidcasetagging" type="int">
<column name="RFIDCASETAGGING" />
</property>
<property name="rfidpallettagging" type="int">
<column name="RFIDPALLETTAGGING" />
</property>
<property name="companychainid" type="java.lang.String">
<column name="COMPANYCHAINID" />
</property>
<property name="companyidsiret" type="java.lang.String">
<column name="COMPANYIDSIRET" />
</property>
<property name="party" type="long">
<column name="PARTY" />
</property>
<property name="identificationnumber" type="java.lang.String">
<column name="IDENTIFICATIONNUMBER" />
</property>
<property name="partycountry" type="java.lang.String">
<column name="PARTYCOUNTRY" />
</property>
<property name="partystate" type="java.lang.String">
<column name="PARTYSTATE" />
</property>
<property name="paymidtype" type="java.lang.String">
<column name="PAYMIDTYPE" />
</property>
<property name="factoringaccount" type="java.lang.String">
<column name="FACTORINGACCOUNT" />
</property>
<property name="defaultdimension" type="long">
<column name="DEFAULTDIMENSION" />
</property>
<property name="custexcludecollectionfee" type="int">
<column name="CUSTEXCLUDECOLLECTIONFEE" />
</property>
<property name="custexcludeinterestcharges" type="int">
<column name="CUSTEXCLUDEINTERESTCHARGES" />
</property>
<property name="companynafcode" type="long">
<column name="COMPANYNAFCODE" />
</property>
<property name="bankcustpaymidtable" type="long">
<column name="BANKCUSTPAYMIDTABLE" />
</property>
<property name="girotypeaccountstatement" type="int">
<column name="GIROTYPEACCOUNTSTATEMENT" />
</property>
<property name="maincontactworker" type="long">
<column name="MAINCONTACTWORKER" />
</property>
<property name="creditcardaddressverification" type="int">
<column name="CREDITCARDADDRESSVERIFICATION" />
</property>
<property name="creditcardcvc" type="int">
<column name="CREDITCARDCVC" />
</property>
<property name="creditcardaddressverificationvoid" type="int">
<column name="CREDITCARDADDRESSVERIFICATIONVOID" />
</property>
<property name="creditcardaddressverificationlevel" type="int">
<column name="CREDITCARDADDRESSVERIFICATIONLEVEL" />
</property>
<property name="companytypeMx" type="int">
<column name="COMPANYTYPEMX" />
</property>
<property name="rfcMx" type="java.lang.String">
<column name="RFCMX" />
</property>
<property name="curpMx" type="java.lang.String">
<column name="CURPMX" />
</property>
<property name="stateinscriptionMx" type="java.lang.String">
<column name="STATEINSCRIPTIONMX" />
</property>
<property name="residenceforeigncountryregionidIt" type="java.lang.String">
<column name="RESIDENCEFOREIGNCOUNTRYREGIONIDIT" />
</property>
<property name="birthcountycodeIt" type="java.lang.String">
<column name="BIRTHCOUNTYCODEIT" />
</property>
<property name="birthdateIt" type="java.util.Date">
<column name="BIRTHDATEIT" />
</property>
<property name="birthplaceIt" type="java.lang.String">
<column name="BIRTHPLACEIT" />
</property>
<property name="einvoice" type="int">
<column name="EINVOICE" />
</property>
<property name="ccmnumBr" type="java.lang.String">
<column name="CCMNUMBR" />
</property>
<property name="cnpjcpfnumBr" type="java.lang.String">
<column name="CNPJCPFNUMBR" />
</property>
<property name="pbacustgroupid" type="java.lang.String">
<column name="PBACUSTGROUPID" />
</property>
<property name="ienumBr" type="java.lang.String">
<column name="IENUMBR" />
</property>
<property name="suframanumberBr" type="java.lang.String">
<column name="SUFRAMANUMBERBR" />
</property>
<property name="suframaBr" type="int">
<column name="SUFRAMABR" />
</property>
<property name="custfinaluserBr" type="int">
<column name="CUSTFINALUSERBR" />
</property>
<property name="interestcodeBr" type="java.lang.String">
<column name="INTERESTCODEBR" />
</property>
<property name="finecodeBr" type="java.lang.String">
<column name="FINECODEBR" />
</property>
<property name="suframapiscofinsBr" type="int">
<column name="SUFRAMAPISCOFINSBR" />
</property>
<property name="taxwithholdcalculateTh" type="int">
<column name="TAXWITHHOLDCALCULATETH" />
</property>
<property name="taxwithholdgroupTh" type="java.lang.String">
<column name="TAXWITHHOLDGROUPTH" />
</property>
<property name="consdayJp" type="int">
<column name="CONSDAYJP" />
</property>
<property name="nitBr" type="java.lang.String">
<column name="NITBR" />
</property>
<property name="inssceiBr" type="java.lang.String">
<column name="INSSCEIBR" />
</property>
<property name="cnaeBr" type="java.lang.String">
<column name="CNAEBR" />
</property>
<property name="icmscontributorBr" type="int">
<column name="ICMSCONTRIBUTORBR" />
</property>
<property name="servicecodeondlvaddressBr" type="int">
<column name="SERVICECODEONDLVADDRESSBR" />
</property>
<property name="inventprofiletypeRu" type="int">
<column name="INVENTPROFILETYPERU" />
</property>
<property name="inventprofileidRu" type="java.lang.String">
<column name="INVENTPROFILEIDRU" />
</property>
<property name="taxwithholdcalculateIn" type="int">
<column name="TAXWITHHOLDCALCULATEIN" />
</property>
<property name="unitedvatinvoiceLt" type="int">
<column name="UNITEDVATINVOICELT" />
</property>
<property name="enterprisecode" type="java.lang.String">
<column name="ENTERPRISECODE" />
</property>
<property name="commercialregistersection" type="java.lang.String">
<column name="COMMERCIALREGISTERSECTION" />
</property>
<property name="commercialregisterinsetnumber" type="java.lang.String">
<column name="COMMERCIALREGISTERINSETNUMBER" />
</property>
<property name="commercialregister" type="java.lang.String">
<column name="COMMERCIALREGISTER" />
</property>
<property name="regnumW" type="java.lang.String">
<column name="REGNUMW" />
</property>
<property name="isresidentLv" type="int">
<column name="ISRESIDENTLV" />
</property>
<property name="intbankLv" type="java.lang.String">
<column name="INTBANKLV" />
</property>
<property name="paymentreferenceEe" type="java.lang.String">
<column name="PAYMENTREFERENCEEE" />
</property>
<property name="packagedepositexcemptPl" type="int">
<column name="PACKAGEDEPOSITEXCEMPTPL" />
</property>
<property name="fednonfedindicator" type="int">
<column name="FEDNONFEDINDICATOR" />
</property>
<property name="irs1099cindicator" type="int">
<column name="IRS1099CINDICATOR" />
</property>
<property name="agencylocationcode" type="java.lang.String">
<column name="AGENCYLOCATIONCODE" />
</property>
<property name="federalcomments" type="java.lang.String">
<column name="FEDERALCOMMENTS" />
</property>
<property name="usepurchrequest" type="int">
<column name="USEPURCHREQUEST" />
</property>
<property name="mcrmergedparent" type="java.lang.String">
<column name="MCRMERGEDPARENT" />
</property>
<property name="mcrmergedroot" type="java.lang.String">
<column name="MCRMERGEDROOT" />
</property>
<property name="affiliatedRu" type="int">
<column name="AFFILIATEDRU" />
</property>
<property name="cashdiscbasedays" type="int">
<column name="CASHDISCBASEDAYS" />
</property>
<property name="custtradingpartnercode" type="long">
<column name="CUSTTRADINGPARTNERCODE" />
</property>
<property name="custwhtcontributiontypeBr" type="int">
<column name="CUSTWHTCONTRIBUTIONTYPEBR" />
</property>
<property name="daxintegrationid" type="java.lang.String">
<column name="DAXINTEGRATIONID" />
</property>
<property name="defaultdirectdebitmandate" type="long">
<column name="DEFAULTDIRECTDEBITMANDATE" />
</property>
<property name="defaultinventstatusid" type="java.lang.String">
<column name="DEFAULTINVENTSTATUSID" />
</property>
<property name="entrycertificaterequiredW" type="int">
<column name="ENTRYCERTIFICATEREQUIREDW" />
</property>
<property name="exportsalesPl" type="int">
<column name="EXPORTSALESPL" />
</property>
<property name="expressbilloflading" type="int">
<column name="EXPRESSBILLOFLADING" />
</property>
<property name="fiscaldoctypePl" type="int">
<column name="FISCALDOCTYPEPL" />
</property>
<property name="foreignresidentRu" type="int">
<column name="FOREIGNRESIDENTRU" />
</property>
<property name="generateincomingfiscaldocumentBr" type="int">
<column name="GENERATEINCOMINGFISCALDOCUMENTBR" />
</property>
<property name="invoicepostingtypeRu" type="int">
<column name="INVOICEPOSTINGTYPERU" />
</property>
<property name="issueownentrycertificateW" type="int">
<column name="ISSUEOWNENTRYCERTIFICATEW" />
</property>
<property name="issuercountryHu" type="java.lang.String">
<column name="ISSUERCOUNTRYHU" />
</property>
<property name="lvpaymtranscodes" type="long">
<column name="LVPAYMTRANSCODES" />
</property>
<property name="mandatoryvatdatePl" type="int">
<column name="MANDATORYVATDATEPL" />
</property>
<property name="passportnoHu" type="java.lang.String">
<column name="PASSPORTNOHU" />
</property>
<property name="pdscustrebategroupid" type="java.lang.String">
<column name="PDSCUSTREBATEGROUPID" />
</property>
<property name="pdsfreightaccrued" type="int">
<column name="PDSFREIGHTACCRUED" />
</property>
<property name="pdsrebatetmagroup" type="java.lang.String">
<column name="PDSREBATETMAGROUP" />
</property>
<property name="taxperiodpaymentcodePl" type="java.lang.String">
<column name="TAXPERIODPAYMENTCODEPL" />
</property>
<property name="usecashdisc" type="int">
<column name="USECASHDISC" />
</property>
<property name="modifieddatetime" type="java.util.Date">
<column name="MODIFIEDDATETIME" />
</property>
<property name="delModifiedtime" type="int">
<column name="DELMODIFIEDTIME" />
</property>
<property name="modifiedby" type="java.lang.String">
<column name="MODIFIEDBY" />
</property>
<property name="createddatetime" type="java.util.Date">
<column name="CREATEDDATETIME" />
</property>
<property name="delCreatedtime" type="int">
<column name="DELCREATEDTIME" />
</property>
<property name="dataareaid" type="java.lang.String">
<column name="DATAAREAID" />
</property>
<property name="recversion" type="int">
<column name="RECVERSION" />
</property>
<property name="partition" type="long">
<column name="PARTITION" />
</property>
<property name="recid" type="long">
<column name="RECID" />
</property>
<property name="einvoiceregisterIt" type="int">
<column name="EINVOICEREGISTERIT" />
</property>
<property name="foreigneridBr" type="java.lang.String">
<column name="FOREIGNERIDBR" />
</property>
<property name="authorityofficeIt" type="java.lang.String">
<column name="AUTHORITYOFFICEIT" />
</property>
<property name="presencetypeBr" type="int">
<column name="PRESENCETYPEBR" />
</property>
<property name="taxgstreliefgroupheadingMy" type="long">
<column name="TAXGSTRELIEFGROUPHEADINGMY" />
</property>
</class>
</hibernate-mapping>
As you can see, the mapping generator gets two things wrong: 1) it identifies an incorrect id; 2) it interprets the CusttableId class as a one-to-many relationship, rather then using it as the id for the Custtable class.
What is the proper way to handle this mapping, to have the CusttableId class mapped as the id for the Custtable class?
You're looking for EmbeddedId or IdClass:
https://docs.jboss.org/hibernate/orm/5.0/mappingGuide/en-US/html/ch06.html#identifiers-composite-nonaggregated
Since judging by provided XML you're using Hibernate 3, you should look into that example:
https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/mapping.html#mapping-declaration-id
In your case you can remove the class and replace incorrect association with:
<composite-id>
<key-property name="accountnum"/>
<key-property name="partition"/>
<key-property name="dataareaid"/>
</composite-id>
I want find all records in table 'users' using hibernate but its allways return empty collection (im sure that some users are in db). My searching function looks like this:
public List<Users> findAll() {
DetachedCriteria criteria = DetachedCriteria.forClass(Users.class);
return getHibernateTemplate().findByCriteria(criteria);
}
Why is not working?
hibernate.cfg.xml:
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/intellidom</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<mapping file="mapping/Users.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Users.hbm.xml:
<hibernate-mapping>
<class name="intellidom.entity.Users" table="users" schema="intellidom">
<id column="id" name="id" type="int" >
<generator class="increment"/>
</id>
<property name="login" column="login" type="java.lang.String"/>
<property name="password" column="password" type="java.lang.String"/>
<property name="firstName" column="firstName" type="java.lang.String"/>
<property name="lastName" column="lastName" type="java.lang.String"/>
</class>
</hibernate-mapping>
The configuration for Affiliate class is:
<class name="AffiliatesDO" table="AFFILIATES">
<id name="affiliateId" column="affiliate_id" type="java.lang.String">
<generator class="assigned" />
</id>
<property name="customerId" column="customer_id" type="int" />
<property name="affiliateType" column="affiliate_type" type="java.lang.String" />
<property name="site" column="site" type="java.lang.String" />
<property name="status" column="status" type="java.lang.String" />
<property name="createdBy" column="created_by" type="java.lang.String" />
<property name="creationDate" column="creation_date" type="java.util.Date" />
<property name="lastUpdatedBy" column="last_updated_by" type="java.lang.String" />
<property name="lastUpdated" column="last_updated" type="java.util.Date" />
<set name="address" lazy="true" inverse="true" order-by="address_id asc">
<key column="address_id"/>
<one-to-many class="AddressDO"/>
</set>
</class>
The Configuration for Address class is
<class name="Address"
table="Address">
<id name="addressId" column="address_id"
type="java.lang.String">
<generator class="assigned" />
</id>
<property name="name" column="name" type="java.lang.String" />
<property name="address1" column="address1" type="java.lang.String" />
<property name="phone" column="phone" type="java.lang.String" />
<property name="landLineNumber" column="land_line_number" type="java.lang.String" />
<property name="faxNumber" column="fax_number" type="java.lang.String" />
</class>
I am getting the below error
org.hibernate.MappingException: Association references unmapped class: com.infibeam.customerservice.dbObjects.AddressDO
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2370)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2652)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1054)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:38)
at org.codehaus.mojo.hibernate3.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:186)
at org.codehaus.mojo.hibernate3.exporter.Hbm2JavaGeneratorMojo.configureExporter(Hbm2JavaGeneratorMojo.java:69)
Kindly show me the mistakes I have made.. I want to use one to many relation AffiliateDO->AddressDO
It looks like your mapping of the parent class is referring to AddressDO, but the subsequent child mapping is referring to Address (No "DO")... If I had to guess, you should change the second mapping to AddressDO (or visa versa). In any event, looks like a typo to me.
Considering Do as a typo error in Addrees xml, The Address mapping seems incorrect, there must address_id must be many-to-one currently it is generated new one.
Currently We are facing a lot of problem in migrating our Application from Hibernate 3.2.5 to 3.6.1.
The first error that We are facing is :
SEVERE: Invalid column name 'btn_name'. Although btn_name is mapped no where. The actual mapping is btnName.
Here is my mapping file
<hibernate-mapping>
<class abstract="true" name="com.sampleproject.client.beansdm.metadata.Component"
table="component_master">
<id column="metadata_id" name="id" type="long">
<generator class="native" />
</id>
<property column="metadata_type" name="type" type="string" />
<property name="createdDateTime" column="created_date" type="date"
update="false"></property>
<property name="version" type="string" column="version_id"></property>
<property name="currentDate" type="date" column="curr_date"></property>
<property name="currentIP" type="string" column="current_ip"></property>
<many-to-one name="currentUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="current_user_id"></many-to-one>
<property name="latestDate" type="date" column="latest_date"></property>
<property name="latestIP" type="string" column="latest_ip"></property>
<many-to-one name="latestUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="latest_user"></many-to-one>
<property name="recordStatus" type="boolean" column="record_status"></property>
<property name="portal" type="string" column="portal"></property>
<many-to-one cascade="refresh,save-update,delete"
class="com.sampleproject.client.beansdm.metadata.Component" column="md_id"
name="metadata" not-null="false" />
<joined-subclass
name="com.sampleproject.client.beansdm.metadata.uicontrols.UIControl"
table="ui_control_master">
<key column="ui_control_id" />
<property column="display_name" name="displayText" />
<property column="help_text" name="helpText" />
<property column="info_text" name="informativeText" />
<property column="rows" name="rows" type="integer" />
<property column="cols" name="cols" type="integer" />
<property column="btnName" name="btnName" type="string" />
<property name="version" type="string" column="version_id"></property>
<property name="currentDate" type="date" column="curr_date"></property>
<property name="currentIP" type="string" column="current_ip"></property>
<many-to-one name="currentUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="current_user_id"></many-to-one>
<property name="latestDate" type="date" column="latest_date"></property>
<property name="latestIP" type="string" column="latest_ip"></property>
<many-to-one name="latestUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="latest_user"></many-to-one>
<property name="recordStatus" type="boolean" column="record_status"></property>
<property name="portal" type="string" column="portal"></property>
<property name="readOnly" type="boolean" column="read_only"/>
<joined-subclass
name="com.sampleproject.client.beansdm.metadata.uicontrols.InputControl"
table="input_control_master" lazy="true">
<key column="input_control_id" />
<property column="default_value" name="defaultValue"
not-null="false" />
<property column="is_fk" name="fk" />
<property column="validatable" name="validatable" />
<property column="violatable" name="violatable" />
<property name="isRequired" column="is_required"></property>
<property name="ruleType"
type="com.sampleproject.facadeimplementation.util1.UserEnumRuleType"
column="rule_type"></property>
<property name="fileType" column="file_type"></property>
<property name="maxFileSize" column="max_file_size" type="integer"></property>
<property name="precision" column="input_precision" type="integer"></property>
<property name="maxLength" column="maxlength" type="integer"></property>
<property name="minLength" column="minlength" type="integer"></property>
<property name="dateFormatType" column="dateformat"
type="com.sampleproject.facadeimplementation.util1.UserEnumDateFormatType"></property>
<property name="specialCharAllow" column="isspecialcharallow"></property>
<property name="specialChars" column="specialchars" type="string"></property>
<property name="dateType"
type="com.sampleproject.facadeimplementation.util1.UserEnumDateType"
column="date_type"></property>
<property name="minDate" column="mindate" type="string"></property>
<property name="maxDate" column="maxdate" type="string"></property>
<property name="inspection" column="inspection" type="boolean"></property>
<property name="values" column="default_values" type="string"></property>
<property name="targetNames" column="target_names" type="string"></property>
<!--
<many-to-one cascade="save-update, delete"
class="com.sampleproject.client.beansdm.metadata.Column"
column="target_column_id" name="targetColumn" />
-->
<property name="targetColumn" column="target_column" type="string"></property>
<property name="templateName" column="template_name" type="string"></property>
<!--
<bag name="targetColumnNames" cascade="save-update"
table="input_possible_columns_map"> <key
column="input_control_id"></key> <element column="column_name"
not-null="true" type="string" /> </bag>
-->
<!--<bag name="possibleValues" cascade="save-update" table="input_possible_values_map">
<key column="input_control_id" />
<many-to-many
class="com.sampleproject.client.beansdm.metadata.uicontrols.PossibleValue"
column="value" />
</bag>
--><property name="seperator" column="seperator" type="string" />
<many-to-one name="refTable" cascade="refresh"
class="com.sampleproject.client.beansdm.metadata.Table" column="ref_table_id" lazy="false">
</many-to-one>
<many-to-one name="targetTable" cascade="refresh"
class="com.sampleproject.client.beansdm.metadata.Table" column="target_table_id" />
<property name="version" type="string" column="version_id"></property>
<property name="currentDate" type="date" column="curr_date"></property>
<property name="currentIP" type="string" column="current_ip"></property>
<many-to-one name="currentUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="current_user_id"></many-to-one>
<property name="latestDate" type="date" column="latest_date"></property>
<property name="latestIP" type="string" column="latest_ip"></property>
<many-to-one name="latestUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="latest_user"></many-to-one>
<property name="recordStatus" type="boolean" column="record_status"></property>
<property name="portal" type="string" column="portal"></property>
<many-to-one name="linkedColumn" cascade="refresh"
class="com.sampleproject.client.beansdm.metadata.Column" column="linked_column_name">
</many-to-one>
<many-to-one name="linkedMasterColumn" cascade="refresh"
class="com.sampleproject.client.beansdm.metadata.Column" column="linked_master_column">
</many-to-one>
<many-to-one name="linkedTable" cascade="refresh"
class="com.sampleproject.client.beansdm.metadata.Table" column="linked_master_id">
</many-to-one>
</joined-subclass>
</joined-subclass>
</class>
</hibernate-mapping>
Focus on com.sampleproject.client.beansdm.metadata.uicontrols.InputControl joined-subclass mapping there is a field named btnName. Its working fine with 3.2.5 version but when i changed it to newer hibernate version it stops responding.
Is there any possible jar conflicts ?
Please help.
Thanking You,
Regards,
The Hibernate Version Comparison guide states when moving from 3.5 to 3.6 that:
However, for users still using hbm.xml
you should be aware that we chose to
use the
org.hibernate.cfg.EJB3NamingStrategy
used in AnnotationConfigration instead
of the older
org.hibernate.cfg.DefaultNamingStrategy
historically used on Configuration.
This may cause naming mismatches; one
known place where this is an issue is
if you rely on the naming strategy to
default the name of a association
(many-to-many and collections of
elements) table. If you find yourself
in this situation, you can tell
Hibernate to use the the legacy
org.hibernate.cfg.DefaultNamingStrategy
by calling
Configuration#setNamingStrategy and
passing it
org.hibernate.cfg.DefaultNamingStrategy#INSTANCE
The NamingStrategy interface defines several methods like String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName)used to determine the names of columns and associations which are implemented by the EJB3NamingStrategy. I suggest you look at the implementation of these methods in the EJB3NamingStrategy class and see how it is transforming property names to column names.
It looks like hibernate is now adding the underscores to what it expects the column name to be in the DB via one these transformations, and is upset when it can't find the resultant column name 'btn_name' in your database.