I am facing following problem,
Inside the database(mssql), i have created a table without primary key. After doing hibernate reverse engineering, by default it has taken composite primary key with all the columns of the table and hibernate s/w has created two pojo classes for that table one is a normal pojo class and another is pojo class for id. Inside the Pojo class id, it has generated properties for all the columns for that table and normal pojo class contains a property for Id pojo class. And i have inserted some records into the table.I have inserted few of the rows with a null value for a column. And i have created a class to retrieve all the records from tha table using hql query. Whenever i call the list() on the Query object it returns a List of pojo class objects. But inside the List object it placed null value for those records which contains a null value for a column instead of getting pojo class object. Please help me in resolving this problem.
I will wait for ur solution.
Lets take a example to undersatnad how to create a composite id in hibernate : First Table :Foo
Columns : 1.name 2.addrid 3.age
Note : Foo has two PK-columns: addr_id and name
Second Table name :Address
Column : id
In hibernate this could be mapped as follows :
<class name="Foo" table="foo"> <composite-id name="id" class="Person"> <key-property name="name" type="string" column="name"/> <key-many-to-one name="address" class="Address" column="addrid"/> </composite-id> <property name="age" column="age" type="string"/> </class> <class name="Address" table="address"> ... </class>