jQuery in Action, 3rd edition
The moose likes Object Relational Mapping and the fly likes Getting error in Hibernate program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Getting error in Hibernate program" Watch "Getting error in Hibernate program" New topic

Getting error in Hibernate program

Vaishali Paramane
Ranch Hand

Joined: Mar 05, 2007
Posts: 107
I am doing one simple program. In my database I don't have primary key.
I am getting following error

My mapping file
<class name="bean.TempPhoneConnectionsBean" table="TEMPPHONECONNECTIONS" schema="SYSTEM">

<id name="userid" type="java.lang.Integer"><column name="USERID" precision="22" scale="0"/></id>

<property name="purpose" type="java.lang.String"><column name="PURPOSE" length="10" /></property>

<property name="facility" type="java.lang.String"><column name="FACILITY" length="5"/></property>
<property name="frmdate" type="java.util.Date"><column name="FRMDATE" length="7"/></property>

<property name="todate" type="java.util.Date" ><column name="TODATE" length="7"/></property>

<property name="bankname" type="java.lang.String"><column name="BANKNAME" length="50"/></property>

<property name="branchncity" type="java.lang.String" ><column name="BRANCHNCITY" length="60"/></property>

<property name="ddno" type="java.lang.String" ><column name="DDNO" length="25"/></property>
<property name="amount" type="java.lang.Float"><column name="AMOUNT" precision="22" scale="0"/></property>

<property name="dateofissue" type="java.util.Date"><column name="DATEOFISSUE" length="7"/></property>



public class test {

public static void main(String[] args) throws Exception{
Configuration cfg =new Configuration().configure();
SessionFactory factory=cfg.buildSessionFactory();
Session ses=factory.openSession();
Transaction tx = ses.beginTransaction();
Query qr = ses.createQuery("* from TempPhoneConnectionsBean");
List lst=qr.list();

Pojo file
public class TempPhoneConnectionsBean {
int userid;
String purpose ;
String facility ;
Date frmdate;
Date todate;
String bankname ;
String branchncity ;
String ddno ;
float amount ;
Date dateofissue ;
** after that all setter and getters


anyone can suggest me is there any wrong in mapping file?

Preparing for SCWCD
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3902

I'm not sure whether asterisk (*) works or not in the query. Are you sure it works? Generally it's of the form "from <POJOClass>" in HQL.

[How to ask questions] [Twitter]
Vaishali Paramane
Ranch Hand

Joined: Mar 05, 2007
Posts: 107
Thanks for reply

Now it is working after removing * and inserting row in database.
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3902

Glad you got it solved
I agree. Here's the link: http://aspose.com/file-tools
subject: Getting error in Hibernate program
It's not a secret anymore!