Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with hibernate AnnotationConfiguration

807588May 13 2008 — edited Feb 3 2009
Hi all,
I have the following in hibernation.cfg.xml file
?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://mysql.wolfram.com:3324/search_info_tst</property>
<property name="hibernate.connection.username">search_user_tst</property>
<property name="hibernate.connection.password">wrselohetst</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<!-- <mapping resource="contact.hbm.xml"/> -->
<mapping class="com..hibernate.Contact"/>
</session-factory>
</hibernate-configuration>

and com.hibernate.Contact.java is as follows

import javax.persistence.*;

@Entity
@Table(name = "test")
public class Contact {
@Id @GeneratedValue
@Column(name = "id")
private int id;
@Column(name = "name")
private String name;
@Column(name = "ssn")
private int ssn;
@Column(name = "email")
private String email;

public void setName(String name){
this.name = name;
}

public String getName(){
return this.name;
}

public void setId(int id){
this.id = id;
}

public int getId(){
return this.id;
}

public void setSsn(int ssn){
this.ssn = ssn;
}

public int getSsn(){
return this.ssn;
}

public void setEmail(String email){
this.email = email;
}

public String getEmail(){
return this.email;
}
}
and in one of my *.java* I have,
SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();

but this returns null... SessionFactory obj is not getting created.. am i doing anything wrong?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 3 2009
Added on May 13 2008
3 comments
297 views