Hibernate not Loading a class
- by Noor
Hi, I have a class Auction that contains a Class Item and Users but when I am getting the class, the class item and Users are not being loaded.
Auction Class Mapping File:
<?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 Dec 28, 2010 9:14:12 PM by Hibernate Tools 3.4.0.Beta1 -->
<hibernate-mapping>
<class name="com.BiddingSystem.Models.Auction" table="AUCTION">
<id name="AuctionId" type="long">
<column name="AUCTIONID" />
<generator class="native" />
</id>
<property name="StartTime" type="java.util.Date">
<column name="STARTTIME" />
</property>
<property name="EndTime" type="java.util.Date">
<column name="ENDTIME" />
</property>
<property name="StartingBid" type="long">
<column name="STARTINGBID" />
</property>
<property name="MinIncrement" type="long">
<column name="MININCREMENT" />
</property>
<many-to-one name="CurrentItem" class="com.BiddingSystem.Models.Item" fetch="join" cascade="all">
<column name="ItemId" />
</many-to-one>
<property name="AuctionStatus" type="java.lang.String">
<column name="AUCTIONSTATUS" />
</property>
<property name="BestBid" type="long">
<column name="BESTBID" />
</property>
<many-to-one name="User" class="com.BiddingSystem.Models.Users" fetch="join">
<column name="UserId" />
</many-to-one>
</class>
</hibernate-mapping>
When I am doing this:
Query query=session.createQuery("from Auction where UserId="+UserId);
List <Auction> AllAuctions= new LinkedList<Auction>(query.list());
The Users and Item are null