Joined: Thu Dec 27, 2012 6:10 pm Posts: 1
|
i am new in using hibernate and for some reason i am getting a list of null objects when i am using the following code: (the table has some rows of data inside it and with a diff table i manage to see the content of the other object) public static void main(String args[]) { Session s = HibernateUtil.currentSession(); ArrayList lst = (ArrayList) s.createQuery("from Users").list(); for(Object obj : lst){ Users user = (Users)obj; System.Out.println(user.getUserid()); // null } } my hibernate mapping xml looks like this:
<?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 27, 2012 9:48:45 PM by Hibernate Tools 3.4.0.CR1 --> <hibernate-mapping> <class name="us.Users" table="USERS"> <id name="userid" type="int"> <column name="USERID" precision="9" scale="0" /> <generator class="assigned" /> </id> <property name="username" type="string"> <column name="USERNAME" length="200" /> </property> <property name="password" type="string"> <column name="PASSWORD" length="200" /> </property> <property name="firstName" type="string"> <column name="FIRST_NAME" length="200" /> </property> <property name="lastName" type="string"> <column name="LAST_NAME" length="200" /> </property> <property name="dateOfBirth" type="timestamp"> // my guess was that the problem appears with the timestamp property <column name="DATE_OF_BIRTH" /> </property> <property name="registrationDate" type="timestamp"> <column name="REGISTRATION_DATE" /> </property> <one-to-one name="administrators" class="assignment2.Administrators"></one-to-one> <set name="histories" table="HISTORY" inverse="true" lazy="false" fetch="select"> <key> <column name="USERID" precision="9" scale="0" not-null="true" /> </key> <one-to-many class="us.History" /> </set> <set name="loginlogs" table="LOGINLOG" inverse="true" lazy="false" fetch="select"> <key> <column name="USERID" precision="9" scale="0" not-null="true" /> </key> <one-to-many class="us.Loginlog" /> </set> </class>
|
|