This class Sample1 does NOT create a database table,
and no Exception is thrown
If you change the property name to "ychange" everything
works fine...
------------------------------------------------------------------------
<?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="org.hibernate.test.bug">
<class name="Sample1">
<id name="id">
<generator class="native"/>
</id>
<property name="symbol"/>
<property name="change"/>
</class>
</hibernate-mapping>
--------------------------------------------------------------------------------
This class Sample2 creates a database table just fine...
--------------------------------------------------------------------------------
<?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="org.hibernate.test.bug">
<class name="Sample2">
<id name="id">
<generator class="native"/>
</id>
<property name="symbol"/>
<property name="xchange"/>
</class>
</hibernate-mapping>
-------------------------------------------------------------------------------
package org.hibernate.test.bug;
public class Sample1 extends Persistent {
private String symbol;
private double change;
public String getSymbol() {
return symbol;
}
public void setSymbol(String s) {
symbol = s;
}
public void setChange(double d) {
change = d;
}
public double getChange() {
return change;
}
}
----------------------------------------------------------------------------------
package org.hibernate.test.bug;
public class Sample2 extends Persistent {
private String symbol;
private double xchange;
public String getSymbol() {
return symbol;
}
public void setSymbol(String s) {
symbol = s;
}
public void setXchange(double d) {
xchange = d;
}
public double getXchange() {
return xchange;
}
}
---------------------------------------------------------------------------------
When the class below is executed, only one database table
gets created, not 2 tables as to be expected...
Only the table Sample2 table gets created,
because in Sample1 the property name is called "change"
no table gets created.
If you change the property name in Sample1 to "ychange",
two database tables get created as would be expected.
Its just when you call a property name "change" that
it seems like weird things happen.
Please advise,
Michael I Angerman
http://www.zrato.com
---------------------------------------------------------------------------------
package org.hibernate.test.bug;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.test.bug.Sample1;
import org.hibernate.test.bug.Sample2;
public class InitDb {
private SessionFactory factory;
public void init() {
Session s = factory.openSession();
Transaction tx=null;
try {
tx = s.beginTransaction();
tx.commit();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
s.close();
}
}
public static void main(String[] args) {
InitDb ix = new InitDb();
Configuration cfg = new Configuration()
.addClass(Sample1.class)
.addClass(Sample2.class)
.setProperty(Environment.HBM2DDL_AUTO, "create");
try {
ix.factory = cfg.buildSessionFactory();
}
catch (HibernateException e) {
e.printStackTrace();
}
ix.init();
ix.factory.close();
}
}