-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate not retreiving data from database views
PostPosted: Fri Aug 06, 2010 11:22 am 
Newbie

Joined: Sat May 01, 2010 9:20 am
Posts: 6
Hello all,

I am trying to query a view for retreiving some data with the following queries

select new BoComponentsVw(id) from BoComponentsVw boComponentView where boComponentView.id.endItem in('261746','71018AA010')

or
from BoComponentsVw boComponentView where boComponentView.id.endItem in('261746','71018AA010')

both are same.

these are the mapping files and entity objects.

<hibernate-mapping>
<class name="com.jci.bots.edw.data.BoComponentsVw" table="BO_COMPONENTS_VW" mutable="false">
<composite-id name="id" class="com.jci.bots.edw.data.BoComponentsVwId" >
<key-property name="siteNbr" type="string">
<column name="SITE_NBR" length="80" />
</key-property>
<key-property name="endItem" type="string">
<column name="END_ITEM" />
</key-property>
<key-property name="componentNme" type="string">
<column name="COMPONENT_NME" />
</key-property>
<key-property name="componentDsc" type="string">
<column name="COMPONENT_DSC" length="80" />
</key-property>
<key-property name="componentUom" type="string">
<column name="COMPONENT_UOM" length="20" />
</key-property>
<key-property name="invoiceUnitPrice" type="big_decimal">
<column name="INVOICE_UNIT_PRICE" precision="22" scale="0" />
</key-property>
<key-property name="supplierSapNbr" type="string">
<column name="SUPPLIER_SAP_NBR" length="20" />
</key-property>
<key-property name="supplierName" type="string">
<column name="SUPPLIER_NAME" length="128" />
</key-property>
<key-property name="scheduleAgreementNbr" type="string">
<column name="SCHEDULE_AGREEMENT_NBR" length="35" />
</key-property>
<key-property name="scheduleAgreementLineNbr" type="string">
<column name="SCHEDULE_AGREEMENT_LINE_NBR" length="6" />
</key-property>
<key-property name="currencyCd" type="string">
<column name="CURRENCY_CD" length="30" />
</key-property>
</composite-id>
</class>

---------------------entity objects ---------------------------

public class BoComponentsVw implements java.io.Serializable {

private BoComponentsVwId id;

public BoComponentsVw() {
}

public BoComponentsVw(BoComponentsVwId id) {
this.id = id;
System.out.println(id);
}

public BoComponentsVwId getId() {
return this.id;
}

public void setId(BoComponentsVwId id) {
this.id = id;
}

}

-------------------id class--------------

public class BoComponentsVwId implements java.io.Serializable {

private String siteNbr;
private String endItem;
private String componentNme;
private String componentDsc;
private String componentUom;
private BigDecimal invoiceUnitPrice;
private String supplierSapNbr;
private String supplierName;
private String scheduleAgreementNbr;
private String scheduleAgreementLineNbr;
private String currencyCd;
.............

it has getters setters and constructors

Now when Itry to do this

List<BoComponentsVw> bocVwList = query.list();


for(BoComponentsVw bocvw1 : bocVwList){
System.out.println(bocvw1.getId());//.getComponentDsc());
}

I get null printed, I dont understand why it is giving null for the getId().

Is there something to be remembered when I handle views.

BTW, I have generated the hbm and java classes using hibernate reverse engineering tool


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.