I am new to hibernate and I am having problem with retrieving values from a view that I created. I have created a mapping file, entity and updated my applicationContext to list the entity in the sessionFactory. My DAO attempts to retrieve all values from the view as a list, but it returns a list of the correct size but all null values. What can be causing this, I have another view and other tables that do not give me this issue. Please advise, is there something that I am missing?
I am using Spring3.0.6 and hibernate 3.6.2
************************hbm.xml***********************
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <!-- Generated Mar 21, 2012 3:57:29 PM by Hibernate Tools 3.4.0.CR1 --> <hibernate-mapping> <class name="View2" table="viewv2" catalog="ordermanagement"> <composite-id name="id" class="entity.ViewV2Id"> <key-property name="parentid" type="long"> <column name="Parentid" /> </key-property> <key-property name="activeChildid" type="java.lang.Long"> <column name="ActiveChildid" /> </key-property> <key-property name="sendingShopCode" type="string"> <column name="SendingShopCode" length="30" /> </key-property> </composite-id> </class> </hibernate-mapping>
*************************DAO***************************
public List<ViewV2> getAllOrders() { List<ViewV2> items = (List<ViewV2>) sessionFactory.getCurrentSession() .createCriteria( ViewV2.class ).list(); return items; } **********************Entity*****************************
@Entity @Table(name = "viewv2", catalog = "ordermanagement") public class View2 implements java.io.Serializable {
private View2Id id;
public View2() { }
public View2(View2Id id) { this.id = id; }
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "parentid", column = @Column(name = "Parentid", nullable = false)), @AttributeOverride(name = "activeChildid", column = @Column(name = "ActiveChildid")), @AttributeOverride(name = "sendingShopCode", column = @Column(name = "SendingShopCode", length = 30)) }) public View2Id getId() { return this.id; }
public void setId(View2Id id) { this.id = id; } ***********Embedded id**********************
@Embeddable public class View2Id implements java.io.Serializable {
private long parentid; private Long activeChildid; private String sendingShopCode;
public View2Id() { }
public View2Id(long parentid, Long activeChildid, String sendingShopCode) { this.parentid = parentid; this.activeChildid = activeChildid; this.sendingShopCode = sendingShopCode; }
@Column(name = "Parentid", nullable = false) public long getParentid() { return this.parentid; }
public void setParentid(long parentid) { this.parentid = parentid; }
@Column(name = "ActiveChildid") public Long getActiveChildid() { return this.activeChildid; }
public void setActiveChildid(Long activeChildid) { this.activeChildid = activeChildid; }
@Column(name = "SendingShopCode", length = 30) public String getSendingShopCode() { return this.sendingShopCode; }
public void setSendingShopCode(String sendingShopCode) { this.sendingShopCode = sendingShopCode; }
|