开发者

Hibernate not Loading a class

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


@ManyToOne(fetch=FetchType.EAGER) would be the annotation based configuration element you are missing. Please refer to the manual to see how to configure this by XML.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜