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: saveOrUpdate can't save a new object? why?
PostPosted: Sun Mar 13, 2005 11:57 pm 
Regular
Regular

Joined: Sat Apr 10, 2004 8:39 pm
Posts: 84
saveOrUpdate 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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 14, 2005 12:28 am 
Regular
Regular

Joined: Sat Apr 10, 2004 8:39 pm
Posts: 84
when use codes it seems no problem, but not insert into database.

session = sessionFactory.openSession();
session.saveOrUpdateCopy(obj);
session.flush();



public void testSaveOrUpdate() {
try {
PigeonholeType pigeonholeType = new PigeonholeType();
pigeonholeType.setSymbol("none");
PigeonholeRule pigeonholeRule = new PigeonholeRule();
pigeonholeRule.setXtypeSymbol("SB006");
pigeonholeRule.setSize(new Integer(456));
pigeonholeRule.setPigeonholeType(pigeonholeType);
pigeonholeRuleDao.saveOrUpdate(pigeonholeRule);

} catch (Exception e) {
e.printStackTrace();
}

PigeonholeRule obj = pigeonholeRuleDao.loadByPrimaryKey("SB006");
System.out.println(obj.getSize());

}



[WARN ] [2005-03-14 11:59:40,015] 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: select pigeonhole0_.XTYPE_SYMBOL as XTYPE_SY1_1_, pigeonhole0_.PIGEONHOLE_TYPE_SYMBOL as PIGEONHO2_1_, pigeonhole0_.SIZE as SIZE1_, pigeonhole1_.SYMBOL as SYMBOL0_, pigeonhole1_.TITLE as TITLE0_ from PIGEONHOLE_RULE pigeonhole0_ left outer join PIGEONHOLE_TYPE pigeonhole1_ on pigeonhole0_.PIGEONHOLE_TYPE_SYMBOL=pigeonhole1_.SYMBOL where pigeonhole0_.XTYPE_SYMBOL=?
Hibernate: insert into PIGEONHOLE_RULE (PIGEONHOLE_TYPE_SYMBOL, SIZE, XTYPE_SYMBOL) values (?, ?, ?)
Hibernate: select pigeonhole0_.XTYPE_SYMBOL as x0_0_ from PIGEONHOLE_RULE pigeonhole0_ where ((pigeonhole0_.XTYPE_SYMBOL=? ))
Hibernate: select pigeonhole0_.XTYPE_SYMBOL as XTYPE_SY1_1_, pigeonhole0_.PIGEONHOLE_TYPE_SYMBOL as PIGEONHO2_1_, pigeonhole0_.SIZE as SIZE1_, pigeonhole1_.SYMBOL as SYMBOL0_, pigeonhole1_.TITLE as TITLE0_ from PIGEONHOLE_RULE pigeonhole0_ left outer join PIGEONHOLE_TYPE pigeonhole1_ on pigeonhole0_.PIGEONHOLE_TYPE_SYMBOL=pigeonhole1_.SYMBOL where pigeonhole0_.XTYPE_SYMBOL=?
Hibernate: select setofpigeo0_.PIGEONHOLE_TYPE_SYMBOL as PIGEONHO2___, setofpigeo0_.XTYPE_SYMBOL as XTYPE_SY1___, setofpigeo0_.XTYPE_SYMBOL as XTYPE_SY1_0_, setofpigeo0_.PIGEONHOLE_TYPE_SYMBOL as PIGEONHO2_0_, setofpigeo0_.SIZE as SIZE0_ from PIGEONHOLE_RULE setofpigeo0_ where setofpigeo0_.PIGEONHOLE_TYPE_SYMBOL=?
456

_________________
I am the creatxr of world.


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.