-->
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: one to many relationship
PostPosted: Thu Jun 11, 2009 1:46 pm 
Newbie

Joined: Thu Jun 11, 2009 1:41 pm
Posts: 1
this is friendlist.hbm.xml

<?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 package="bean">
<class name="Profile" table="Profile">
<id name="Id" type="int">
<generator class="assigned"/>
</id>
<property name="Designation" type="string"/>
<property name="FirstName" column="First_Name" />
<property name="LastName" column="Last_Name" />
<property name="UserName" column="UserName" />
<property name="Password" column="Password" />
<property name="Email" column="Email" />
<property name="Nationality" column="nationality_id" />
<property name="City" column="city" />
<property name="Photo" column="Photo" />
<list name="FriendLists" cascade="all">
<key column="parent_id"/>
<index column="idx"/>
<one-to-many class="FriendList"/>
</list>
</class>
<class name="FriendList" table="FriendLists">
<id name="FId" type="int">
<generator class="assigned"/>
</id>
<property name="FScraps" type="string"/>
<property name="PersonId" type="int"/>
<property name="FName" type="string"/>
</class>
</hibernate-mapping>

this is hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:praju123</property>
<property name="connection.username">travel</property>
<property name="connection.password">travel</property>
<property name="dialect">org.hibernate.dialect.Oracle8iDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.jdbc.batch_size">40</property>
<!-- <mapping resource="Profile.hbm.xml"/> -->
<mapping resource="Friendlist.hbm.xml"/>
<mapping resource="film.hbm.xml"/>
</session-factory>
</hibernate-configuration>

this is jsp

<%@page import="bean.*,org.hibernate.Transaction,java.util.Iterator,java.util.*,org.hibernate.Query,org.hibernate.Session,org.hibernate.SessionFactory,org.hibernate.cfg.Configuration" contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>

<%
Session session1 = null;
SessionFactory factory;

try
{
factory=new Configuration().configure().buildSessionFactory();
session1=factory.openSession();
Transaction tr=session1.beginTransaction();
//String scraps=(String)request.getParameter("Scraps");
Profile m1=new Profile();
m1.setId(901);
m1.setDesignation("MISS");

ArrayList list=new ArrayList();
//list.add(new FriendList(101,"prajakta"));
FriendList f= new FriendList();
f.setFId(1190);
f.setFName("praju");
f.setFScraps("scraps");
list.add(f);

m1.setFriendLists(list);
session1.save(m1);

tr.commit();
System.out.println("Record Added");

}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
session1.flush();
session1.close();
}
%>
</body>
</html>


I am new user of hibernate. so please clear my doubt that i got error that


org.apache.jasper.JasperException: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

root cause

org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

root cause

oracle.jdbc2.BatchUpdateException: ORA-00904: invalid column name


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.