-->
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: Unable To Fetch Data From Databse .
PostPosted: Fri May 18, 2012 4:07 am 
Newbie

Joined: Fri May 18, 2012 3:49 am
Posts: 1
Hi i am new Bee in Hibernates i have two table SharedTrackingDetails and table SharedDocDetail table SharedTrackingDetails has primary key SHARED_ID which is foreign key in table SharedDocDetail now my problem is i am unable to fetch data from SharedDocDetail it is throwing error message in HQL as

org.hibernate.QueryException: could not resolve property: SHARED_ID of: com.hds.dal.common.SharedDocDetail [from com.hds.dal.common.SharedDocDetail c,com.hds.dal.common.SharedTrackingDetails d where c.SHARED_ID=32]

My code for SharedDocDetail

Code:





public class SharedDocDetail
{
   private long PK_ID;//----------primary key
   private String did;
   private String dDocName;
   private SharedTrackingDetails sharedTrkDeatils;


   public String getdDocName()
      {
      return dDocName;
      }

   public long getPK_ID()
       {
       return PK_ID;
       }

   public void setPK_ID(long pK_ID)
       {
       PK_ID = pK_ID;
       }

   public void setdDocName(String dDocName)
      {
      this.dDocName = dDocName;
      }

   public String getDid()
      {
      return did;
      }

   public void setDid(String did)
      {
      this.did = did;
      }

   public SharedTrackingDetails getSharedTrkDeatils()
      {
      return sharedTrkDeatils;
      }

   public void setSharedTrkDeatils(SharedTrackingDetails sharedTrkDeatils)
      {
      this.sharedTrkDeatils = sharedTrkDeatils;
      }







}











My code for SharedTrackingDetails

Code:





import java.util.Date;
import java.util.Set;

public class SharedTrackingDetails
{
   private long SHARED_ID;//---------------primary key
   private String sharedBy;
   private String sharedTo;
   private Date startDate;
   private Date endDate;
   private Date requestedDate;
   private Set<SharedDocDetail> documentIdSet;

   public long getSHARED_ID()
      {
      return SHARED_ID;
      }

   public void setSHARED_ID(long sHARED_ID)
      {
      SHARED_ID = sHARED_ID;
      }

   public String getSharedBy()
      {
      return sharedBy;
      }

   public void setSharedBy(String sharedBy)
      {
      this.sharedBy = sharedBy;
      }

   public String getSharedTo()
      {
      return sharedTo;
      }

   public void setSharedTo(String sharedTo)
      {
      this.sharedTo = sharedTo;
      }

   public Date getStartDate()
      {
      return startDate;
      }

   public void setStartDate(Date startDate)
      {
      this.startDate = startDate;
      }

   public Date getEndDate()
      {
      return endDate;
      }

   public void setEndDate(Date endDate)
      {
      this.endDate = endDate;
      }

   public Date getRequestedDate()
      {
      return requestedDate;
      }

   public void setRequestedDate(Date requestedDate)
      {
      this.requestedDate = requestedDate;
      }

   public Set<SharedDocDetail> getDocumentIdSet()
      {
      return documentIdSet;
      }

   public void setDocumentIdSet(Set<SharedDocDetail> documentIdSet)
      {
      this.documentIdSet = documentIdSet;
      }

}










HBM FILE FOR SharedDocDetail

Code:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

   <class name="com.hds.dal.common.SharedDocDetail" table="SHAREDDOCUMENTDETAILS">
   
      <id name="PK_ID" type="long">
         <column name="PK_ID" />
         <generator class="sequence">
            <param name="sequence">SHAREDDOC_SEQ</param>
         </generator>
      </id>
      
      <property name="did" type="text">
         <column name="DOCUMENTID" not-null="false" />
      </property>
   
      <property name="dDocName" type="text">
         <column name="DDOCNAME" not-null="false" />
      </property>
      
       <many-to-one name="sharedTrkDeatils" class="com.hds.dal.common.SharedTrackingDetails" fetch="select">
            <column name="SHARED_ID" not-null="true" />
        </many-to-one>
      
   </class>
   
</hibernate-mapping>






HBM FILE FOR SharedTracking Details


Code:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

   <class name="com.hds.dal.common.SharedTrackingDetails" table="SHAREDTRACKINGDETAILS">
   
      <id name="SHARED_ID" type="long">
         <column name="SHARED_ID" />
         <generator class="sequence">
            <param name="sequence">SHAREDTRACKING_SEQ</param>
         </generator>
      </id>
      
      <set name="documentIdSet"  table = "com.hds.dal.common.SharedDocDetail" inverse="true" lazy="false" fetch="select">
              <key>
                <column name="SHARED_ID" not-null="true" />
            </key>
         <one-to-many class="com.hds.dal.common.SharedDocDetail" />
      </set>
      
      <property name="sharedBy" type="text">
         <column name="SHAREDBY" not-null="false" />
      </property>
      
      <property name="sharedTo" type="text">
         <column name="SHAREDTO" />
      </property>
      
      <property name="startDate" type="timestamp">
         <column name="STARTDATE" not-null="false" />
      </property>

      <property name="endDate" type="timestamp">
         <column name="ENDDATE" not-null="false" />
      </property>
      
      <property name="requestedDate" type="timestamp">
         <column name="REQUESTEDDATE" not-null="false" />
      </property>
      
   </class>
   
</hibernate-mapping>











Data is saved in database ...without any problems but when i try to fetch is Using query

My code for fetching data is
Code:


    
      try{
          Session session = null;
         session = HibernateUtil.getSessionFactory().openSession();
      
      Query qry = session.createQuery("from " + shareddocumentdetails + " c  where  c.SHARED_ID=32");// throws error here
         System.out.println(qry);
         List result = qry.list();
         
       }
catch(Throwable e1)
   {
   System.out.println(e1);
   }
   


Error
could not resolve property: SHARED_ID of: com.hds.dal.common.SharedDocDetail



Please help me i am really a new bee and need this urgent.

Regards
Sachin


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.