- This topic has 4 replies, 2 voices, and was last updated 17 years, 2 months ago by Riyad Kalla.
-
AuthorPosts
-
ssuyambooMemberI am trying to establish relationship between five tables and hbm.xml are like below,
commission model:
<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd”>
<!–
Mapping file autogenerated by MyEclipse Persistence Tools
–>
<hibernate-mapping>
<class name=”com.xpedx.Commissionmodel” table=”commissionmodel” schema=”public”>
<id name=”modelid” type=”java.lang.String”>
<column name=”modelid” length=”10″ />
<generator class=”assigned” />
</id>
<property name=”modeldescription” type=”java.lang.String”>
<column name=”modeldescription” length=”50″ />
</property>
<property name=”basecommissionrate” type=”java.lang.Double”>
<column name=”basecommissionrate” precision=”17″ scale=”17″ />
</property>
<property name=”agedcommissionrate” type=”java.lang.Double”>
<column name=”agedcommissionrate” precision=”17″ scale=”17″ />
</property>
<property name=”freightcostflag” type=”java.lang.Byte”>
<column name=”freightcostflag” />
</property>
<property name=”freightincomeflag” type=”java.lang.Byte”>
<column name=”freightincomeflag” />
</property>
<property name=”deductunpaidinvoiceflag” type=”java.lang.Byte”>
<column name=”deductunpaidinvoiceflag” />
</property>
<property name=”load” type=”java.lang.Double”>
<column name=”load” precision=”17″ scale=”17″ />
</property>
<property name=”maximumgmpct” type=”java.lang.Double”>
<column name=”maximumgmpct” precision=”17″ scale=”17″ />
</property>
<property name=”minimumgmpct” type=”java.lang.Double”>
<column name=”minimumgmpct” precision=”17″ scale=”17″ />
</property>
<property name=”minimumdefaultgmpct” type=”java.lang.Double”>
<column name=”minimumdefaultgmpct” precision=”17″ scale=”17″ />
</property>
<property name=”createdate” type=”java.util.Date”>
<column name=”createdate” length=”29″ />
</property>
<property name=”createdby” type=”java.lang.String”>
<column name=”createdby” length=”10″ />
</property>
<property name=”changedate” type=”java.util.Date”>
<column name=”changedate” length=”29″ />
</property>
<property name=”changedby” type=”java.lang.String”>
<column name=”changedby” length=”10″ />
</property>
<set name=”salesreps” inverse=”true”>
<key>
<column name=”modelid” length=”10″ />
</key>
<one-to-many class=”com.xpedx.Salesrep” />
</set>
</class>
</hibernate-mapping>manager:
<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd”>
<!–
Mapping file autogenerated by MyEclipse Persistence Tools
–>
<hibernate-mapping>
<class name=”com.xpedx.Manager” table=”manager” schema=”public”>
<id name=”managerid” type=”java.lang.String”>
<column name=”managerid” length=”10″ />
<generator class=”assigned” />
</id>
<property name=”managersmgrid” type=”java.lang.String”>
<column name=”managersmgrid” length=”10″ />
</property>
<property name=”managerfirstname” type=”java.lang.String”>
<column name=”managerfirstname” length=”15″ />
</property>
<property name=”managerlastname” type=”java.lang.String”>
<column name=”managerlastname” length=”25″ />
</property>
<property name=”emailaddresslist1″ type=”java.lang.String”>
<column name=”emailaddresslist1″ length=”50″ />
</property>
<property name=”emailaddresslist2″ type=”java.lang.String”>
<column name=”emailaddresslist2″ length=”50″ />
</property>
<property name=”emailaddresslist3″ type=”java.lang.String”>
<column name=”emailaddresslist3″ length=”50″ />
</property>
<set name=”salesreps” inverse=”true”>
<key>
<column name=”managerid” length=”10″ />
</key>
<one-to-many class=”com.xpedx.Salesrep” />
</set>
</class>
</hibernate-mapping>Sales Rep
<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd”>
<!–
Mapping file autogenerated by MyEclipse Persistence Tools
–>
<hibernate-mapping>
<class name=”com.xpedx.Salesrep” table=”salesrep” schema=”public”>
<id name=”salesrep” type=”java.lang.String”>
<column name=”salesrep” length=”10″ />
<generator class=”assigned” />
</id>
<many-to-one name=”commissionmodel” class=”com.xpedx.Commissionmodel” fetch=”select”>
<column name=”modelid” length=”10″ />
</many-to-one>
<many-to-one name=”manager” class=”com.xpedx.Manager” fetch=”select”>
<column name=”managerid” length=”10″ />
</many-to-one>
<property name=”sapid” type=”java.lang.String”>
<column name=”sapid” length=”10″ />
</property>
<property name=”lastname” type=”java.lang.String”>
<column name=”lastname” length=”25″ />
</property>
<property name=”firstname” type=”java.lang.String”>
<column name=”firstname” length=”15″ />
</property>
<property name=”emailaddress” type=”java.lang.String”>
<column name=”emailaddress” length=”50″ />
</property>
<property name=”managerflag” type=”java.lang.Byte”>
<column name=”managerflag” />
</property>
<property name=”merchantstore” type=”java.lang.String”>
<column name=”merchantstore” length=”1″ />
</property>
<property name=”createdby” type=”java.lang.String”>
<column name=”createdby” length=”10″ />
</property>
<property name=”createdate” type=”java.util.Date”>
<column name=”createdate” length=”29″ />
</property>
<property name=”changedby” type=”java.lang.String”>
<column name=”changedby” length=”10″ />
</property>
<property name=”changedate” type=”java.util.Date”>
<column name=”changedate” length=”29″ />
</property>
<set name=”transactionheaderses” inverse=”true”>
<key>
<column name=”ticketsalesrep” length=”10″ />
</key>
<one-to-many class=”com.xpedx.Transactionheaders” />
</set>
</class>
</hibernate-mapping>Transaction Header
<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd”>
<!–
Mapping file autogenerated by MyEclipse Persistence Tools
–>
<hibernate-mapping>
<class name=”com.xpedx.Transactionheaders” table=”transactionheaders” schema=”public” lazy=”true”>
<composite-id name=”id” class=”com.xpedx.TransactionheadersId”>
<key-property name=”store” type=”java.lang.String”>
<column name=”store” length=”3″ />
</key-property>
<key-property name=”date” type=”java.util.Date”>
<column name=”date” length=”29″ />
</key-property>
<key-property name=”ticketnumber” type=”java.lang.String”>
<column name=”ticketnumber” length=”6″ />
</key-property>
<key-property name=”ticketsequence” type=”java.lang.String”>
<column name=”ticketsequence” length=”3″ />
</key-property>
</composite-id>
<many-to-one name=”salesrep” class=”com.xpedx.Salesrep” fetch=”select”>
<column name=”ticketsalesrep” length=”10″ />
</many-to-one>
<property name=”id_1″ type=”java.lang.Integer”>
<column name=”id” not-null=”true” />
</property>
<property name=”custsalesrep” type=”java.lang.String”>
<column name=”custsalesrep” length=”10″ />
</property>
<property name=”salesrepused” type=”java.lang.String”>
<column name=”salesrepused” length=”10″ />
</property>
<property name=”customernumber” type=”java.lang.String”>
<column name=”customernumber” length=”12″ />
</property>
<property name=”customername” type=”java.lang.String”>
<column name=”customername” length=”25″ />
</property>
<property name=”headercommissionamt” type=”java.lang.Double”>
<column name=”headercommissionamt” precision=”17″ scale=”17″ />
</property>
<set name=”transactionlineses” inverse=”true”>
<key>
<column name=”store” length=”3″ not-null=”true” />
<column name=”date” length=”29″ not-null=”true” />
<column name=”ticketnumber” length=”6″ not-null=”true” />
<column name=”ticketsequence” length=”3″ not-null=”true” />
</key>
<one-to-many class=”com.xpedx.Transactionlines” />
</set>
</class>
</hibernate-mapping>Transaction detail
<?xml version=”1.0″ encoding=”utf-8″?>
<!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd”>
<!–
Mapping file autogenerated by MyEclipse Persistence Tools
–>
<hibernate-mapping>
<class name=”com.xpedx.Transactionlines” table=”transactionlines” schema=”public”>
<composite-id name=”id” class=”com.xpedx.TransactionlinesId”>
<key-property name=”store” type=”java.lang.String”>
<column name=”store” length=”3″ />
</key-property>
<key-property name=”date” type=”java.util.Date”>
<column name=”date” length=”29″ />
</key-property>
<key-property name=”ticketnumber” type=”java.lang.String”>
<column name=”ticketnumber” length=”6″ />
</key-property>
<key-property name=”ticketsequence” type=”java.lang.String”>
<column name=”ticketsequence” length=”3″ />
</key-property>
<key-property name=”recordtype” type=”java.lang.String”>
<column name=”recordtype” length=”1″ />
</key-property>
<key-property name=”linenumber” type=”java.lang.String”>
<column name=”linenumber” length=”5″ />
</key-property>
<key-property name=”processdate” type=”java.util.Date”>
<column name=”processdate” length=”29″ />
</key-property>
</composite-id>
<many-to-one name=”transactionheaders” class=”com.xpedx.Transactionheaders” update=”false” insert=”false” fetch=”select”>
<column name=”store” length=”3″ not-null=”true” />
<column name=”date” length=”29″ not-null=”true” />
<column name=”ticketnumber” length=”6″ not-null=”true” />
<column name=”ticketsequence” length=”3″ not-null=”true” />
</many-to-one>
<property name=”itemnumber” type=”java.lang.String”>
<column name=”itemnumber” length=”15″ />
</property>
<property name=”itemdescription1″ type=”java.lang.String”>
<column name=”itemdescription1″ length=”25″ />
</property>
<property name=”itemdescription2″ type=”java.lang.String”>
<column name=”itemdescription2″ length=”25″ />
</property>
<property name=”itemprimevendor” type=”java.lang.String”>
<column name=”itemprimevendor” length=”12″ />
</property>
<property name=”primevendorpart” type=”java.lang.String”>
<column name=”primevendorpart” length=”15″ />
</property>
<property name=”itemtype” type=”java.lang.String”>
<column name=”itemtype” length=”1″ />
</property>
<property name=”quantitysold” type=”java.lang.Double”>
<column name=”quantitysold” precision=”17″ scale=”17″ />
</property>
<property name=”unitofmeasure” type=”java.lang.String”>
<column name=”unitofmeasure” length=”5″ />
</property>
<property name=”linecost” type=”java.lang.Double”>
<column name=”linecost” precision=”17″ scale=”17″ />
</property>
<property name=”linestdcost” type=”java.lang.Double”>
<column name=”linestdcost” precision=”17″ scale=”17″ />
</property>
<property name=”linecostused” type=”java.lang.Double”>
<column name=”linecostused” precision=”17″ scale=”17″ />
</property>
<property name=”netlinesalesprice” type=”java.lang.Double”>
<column name=”netlinesalesprice” precision=”17″ scale=”17″ />
</property>
<property name=”priceoverridecode” type=”java.lang.String”>
<column name=”priceoverridecode” length=”1″ />
</property>
<property name=”commissioncalcmethod” type=”java.lang.String”>
<column name=”commissioncalcmethod” length=”1″ />
</property>
<property name=”linecommissionamount” type=”java.lang.Double”>
<column name=”linecommissionamount” precision=”17″ scale=”17″ />
</property>
<property name=”createdby” type=”java.lang.String”>
<column name=”createdby” length=”10″ />
</property>
</class>
</hibernate-mapping>Transaction header to transaction line 1..*
Transaction header to sales rep 1..1
sales rep to model 1..1
sales rep to manager 1..1I used myeclipse reverse enginerring option to generate all artifacts needed. I wrote a test class to load tranaction header like below,
TransactionheadersDAO dao = new TransactionheadersDAO();
TransactionheadersId transactionId = new TransactionheadersId();
SimpleDateFormat format = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss.S”);Calendar cal = Calendar.getInstance();
cal.set(2007, 05, 01);transactionId.setDate(cal.getTime());
transactionId.setStore(“002”);
transactionId.setTicketnumber(“508583”);
transactionId.setTicketsequence(“001”);Transactionheaders headerList = dao.findById(transactionId);
I was thrown with error as below,
org.hibernate.exception.SQLGrammarException: could not load an entity: com.xpedx.Transactionheaders#component[store,date,ticketnumber,ticketsequence]{ticketsequence=001, ticketnumber=508583, store=002, date=2007-06-01 14:31:33}]
When I tried to debug , I got additional message like
Caused by: org.postgresql.util.PSQLException: ERROR: relation “public.transactionheaders” does not exist
But transactionheaders exists in the database.
Hibernate version 3.1
postgres 8.3[/b]
Is this because of any known issue? Can you help on this?
Thanks
Sundar
Riyad KallaMemberSundar did you use MyEclipse to generate this?
ssuyambooMemberYes I used myeclipse to generate all hbm.xmls
ssuyambooMemberI generated hbm.xml using myeclipse and I am having hard time to retrieve data using generated DAOs.
Can anyone give atleast give hint on this?
Sundar
Riyad KallaMemberSundar,
Can you send me the project you are working with so I can take a look at it? -
AuthorPosts