saveOrUpdateCopy can save a new Object, but
saveOrUpdate can't save a new object? why?
public void testSaveOrUpdate() {
PigeonholeType pigeonholeType = new PigeonholeType();
pigeonholeType.setSymbol("none");
PigeonholeRule pigeonholeRule = new PigeonholeRule();
pigeonholeRule.setXtypeSymbol("SB006");
pigeonholeRule.setSize(new Integer(0));
pigeonholeRule.setPigeonholeType(pigeonholeType);
pigeonholeRuleDao.saveOrUpdate(pigeonholeRule);
}
public Serializable saveOrUpdate(PigeonholeRule obj)
throws HibernateException
{
session = sessionFactory.openSession();
x = session.beginTransaction();
session.saveOrUpdateCopy(obj);
tx.commit();
}
[WARN ] [2005-03-14 11:28:01,750] net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/WORK/fjky-fzgs/project/web/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
Hibernate: update PIGEONHOLE_RULE set PIGEONHOLE_TYPE_SYMBOL=?, SIZE=? where XTYPE_SYMBOL=?
[ERROR] [2005-03-14 11:28:03,640] net.sf.hibernate.impl.SessionImpl - Could not synchronize database state with session
org.springframework.orm.hibernate.HibernateSystemException: Batch update row count wrong: 0; nested exception is net.sf.hibernate.HibernateException: Batch update row count wrong: 0
net.sf.hibernate.HibernateException: Batch update row count wrong: 0
Hibernate: select pigeonhole0_.XTYPE_SYMBOL as x0_0_ from PIGEONHOLE_RULE pigeonhole0_ where ((pigeonhole0_.XTYPE_SYMBOL=? ))
=============SQLs========================
create table xtype (
symbol varchar(16) not null,
title varchar(30) default 'no title' not null,
note varchar(256),
primary key(symbol)
);
create table pigeonhole_type ( symbol varchar(16) not null,
title varchar(32) not null,
primary key(symbol)
);
create table pigeonhole_rule (
xtype_symbol varchar(16) not null,
pigeonhole_type_symbol varchar(16),
size integer default 1,
primary key(xtype_symbol),
foreign key(xtype_symbol) references xtype(symbol),
foreign key(pigeonhole_type_symbol) references pigeonhole_type(symbol)
);
_________________ I am the creatxr of world.
|