Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.0
Mapping documents:profile.hbm.xml
Code between sessionFactory.openSession() and session.close():
Code:
Session session = null;
try{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
Transaction t = session.beginTransaction();
System.out.println("Inserting Record");
Profile regUser = new Profile();
String temp=getUserName();
regUser.setUserName(temp);
regUser.setPassword(getPassword());
regUser.setDOB(getDOB());
regUser.setAddress(getAddress());
regUser.setEmailId(getEmailId());
regUser.setNickname(getNickname());
regUser.setUserStatus("active");
session.save(regUser);
t.commit();
System.out.println("Done");
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
finally
{
// Actual contact insertion will happen at this step
session.flush();
session.close();
}[/b]
[b]Full stack trace of any exception that occurs:could not parse mapping document from resource profile.hbm.xmlName and version of the database you are using:MySQL 5.0The generated SQL (show_sql=true):its not getting generated.Before opening session it is giving this exceptionPOJO class is :
Code:
package buddylist;
import java.util.Date;
public class Profile {
private long userId;
private String userName;
private Date DOB;
private String address;
private String emailId;
private String nickname;
private String userStatus;
private String password;
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Date getDOB() {
return DOB;
}
public void setDOB(Date dob) {
DOB = dob;
}
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserStatus() {
return userStatus;
}
public void setUserStatus(String userStatus) {
this.userStatus = userStatus;
}
}
profile.hbm.xmlCode:
<?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="buddylist.Profile" table="profile">
<id name="userId" type="long" column="UserId" >
<generator class="increment"/>
</id>
<property name="username" column="UserName"/>
<property name="password" column="Password"/>
<property name="DOB" type="timestamp" column="DOB"/>
<property name="address" column="Address"/>
<property name="emailId" column="Email_id"/>
<property name="nickname" column="Nickname"/>
<property name="userStatus" column="User_status"/>
</class>
</hibernate-mapping>
i cant find any mistake. Plz help me.
[/i]