-->
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.  [ 2 posts ] 
Author Message
 Post subject: Property Name Can Not be called "change", is this
PostPosted: Tue Aug 09, 2005 8:03 pm 
Newbie

Joined: Fri Jan 02, 2004 12:38 am
Posts: 1
Location: Albuquerque, New Mexico
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();
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 8:05 pm 
Senior
Senior

Joined: Thu May 12, 2005 11:40 pm
Posts: 125
Location: Canada
Try putting backticks around it

<property name="`change`"/>

(The key to the left of the "1")


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.