aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Getting error in Hibernate program" Watch "Getting error in Hibernate program" New topic
Author

Getting error in Hibernate program

Vaishali Paramane
Ranch Hand

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


My mapping file
<hibernate-mapping>
<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>


</class>
</hibernate-mapping>



test.java

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();
System.out.println(lst.get(0));
}
}


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
}


database

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


SCJP, SCJD
Preparing for SCWCD
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

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.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vaishali Paramane
Ranch Hand

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

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

Joined: Mar 24, 2008
Posts: 3775

Glad you got it solved
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting error in Hibernate program
 
Similar Threads
date mapping problem in Hibernet
org.hibernate.hql.ast.QuerySyntaxException: INFORMATION_SCHEMA.SYSTEM_ALIASES is not mapped.
Not able to execute Select and delete queries
error in running HQL Query
Table not mapped.