Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0
I use MySQL 5.0. When I try to save some example object to database I have sth like this
Quote:
Hibernate: insert into Sample (nr, description) values (?, ?)
and of course no row is added to appropriate table. What can be the reason of this. This is my class:
Code:
/**
* @hibernate.class table = "Sample"
*
*/
public class Sample {
private Long id;
private int nr;
private String description;
public Sample() {
super();
// TODO Auto-generated constructor stub
}
public Sample(int nr, String description) {
super();
// TODO Auto-generated constructor stub
this.nr = nr;
this.description = description;
}
/**
* @hibernate.id column = "sample_id"
* generator-class = "identity"
*/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
* @hibernate.property column = "nr"
* not-null="false"
*/
public int getNr() {
return nr;
}
public void setNr(int nr) {
this.nr = nr;
}
/**
* @hibernate.property column = "description"
* not-null="false"
* length="100"
*/
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
and this is my cfg file:
Code:
<?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="hibernate.connection.username">root</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate</property>
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">true</property>
<!-- -->
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- configuration pool via c3p0
-->
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">100</property>
<!-- seconds
-->
<property name="c3p0.max_size">50</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.min_size">4</property>
<property name="c3p0.timeout">100</property>
<!-- seconds
-->
<!-- DEPRECATED very expensive property name="c3p0.validate>
-->
<mapping resource="mapping\simple_inheritance\Osoba.hbm.xml"/>
<mapping resource="mapping\simple_inheritance\Sample.hbm.xml"/>
</session-factory>
</hibernate-configuration>