I have a problem, using saveOrUpdate or update methods, my DB isn't written.
No error messages are returned, No rollbacks happen.
Do you have any ideas?
Hibernate version:
2.1.4
Mapping documents:
<!DOCTYPE hibernate-mapping SYSTEM "C:\java\eclipse\workspace\portal\hibernate-mapping-2.0.dtd">
<hibernate-mapping default-cascade="save-update" package="it.rvspm.siscotel.portal.dao">
<!-- WebObject Class -->
<class name="it.rvspm.siscotel.portal.dao.WebObject" table="WEBOBJECT">
<meta attribute="extends">
it.rvspm.siscotel.portal.dao.AbstractWebObject
</meta>
<id name="id" type="long">
<column name="id"/>
<generator class="native"/>
</id>
<property name="published" type="boolean"/>
<property name="template" type="string"/>
<!-- Metadata -->
<property name="createdby" type="string"/>
<property name="itemType" type="string"/>
<property name="created" type="date"/>
<property name="expire" type="date"/>
<property name="modified" type="date"/>
<property name="modifiedby" type="string"/>
<!-- More then one??? -->
<property name="category" type="string"/>
<!-- Nome del comune -->
<property name="owner" type="string"/>
<joined-subclass name="it.rvspm.siscotel.portal.dao.Page" table="PAGE">
<key column="id" foreign-key="pageId"/>
<property name="title" type="string"/>
<property name="name" type="string"/>
<property name="navBarposition" type="long"/>
<set name="pubblications" inverse="true" cascade="all" order-by="horizzontalposition asc">
<key column="page"/>
<one-to-many class="it.rvspm.siscotel.portal.dao.Pubblication"/>
</set>
<set name="subpages" >
<key column="superpage"/>
<one-to-many class="it.rvspm.siscotel.portal.dao.Page"/>
</set>
</joined-subclass>
<joined-subclass name="it.rvspm.siscotel.portal.dao.Content" table="CONTENT">
<key column="id" foreign-key="contentId"/>
<property name="title" type="string"/>
<bag name="pubblications" inverse="true" cascade="all">
<key column="content"/>
<one-to-many class="it.rvspm.siscotel.portal.dao.Pubblication"/>
</bag>
<joined-subclass name="it.rvspm.siscotel.portal.dao.Article" table="ARTICLE">
<key column="id" foreign-key="articleId"/>
<property name="body" type="string"/>
</joined-subclass>
<joined-subclass name="it.rvspm.siscotel.portal.dao.News" table="NEWS">
<key column="id" foreign-key="newsId"/>
<property name="body" type="string"/>
</joined-subclass>
</joined-subclass>
<joined-subclass name="it.rvspm.siscotel.portal.dao.Pubblication" table="PUBBLICATION">
<key column="id" foreign-key="pubblicationId"/>
<property name="verticalposition" type="int"/>
<property name="horizzontalposition" type="long"/>
<many-to-one name="page" class="it.rvspm.siscotel.portal.dao.Page"/>
<many-to-one name="content" class="it.rvspm.siscotel.portal.dao.Content"/>
</joined-subclass>
<!--
<joined-subclass name="it.rvspm.siscotel.portal.dao.StructLink" table="STRUCTLINK">
<key column="id" foreign-key="structlinkId"/>
<property name="type" type="string"/>
<many-to-one name="sourcePage" class="it.rvspm.siscotel.portal.dao.Page"/>
<many-to-one name="destinationPage" class="it.rvspm.siscotel.portal.dao.Page"/>
<joined-subclass name="it.rvspm.siscotel.portal.dao.Section" table="SECTIONS">
<key column="id" foreign-key="sectionsId"/>
only one parent page contrined managed by applications
</joined-subclass>
</joined-subclass> -->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Transaction tx = null;
Session session = null;
List pubblications=null;
try {
Logger.getLogger(loggerName).debug("moveDown : "+pubblication);
session = factory.openSession();
tx = session.beginTransaction();
pubblications = session.createCriteria(Pubblication.class).addOrder(Order.desc("horizzontalposition")).list();
Logger.getLogger(loggerName).debug("getPubblication pubblications.size: "+pubblications.size());
Logger.getLogger(loggerName).debug("getPubblication pubblications: "+pubblications);
Iterator iter = pubblications.iterator();
Pubblication upperPubblication = null;
while ( iter.hasNext() ) {
Pubblication pub = (Pubblication)iter.next();
Logger.getLogger(loggerName).debug("upperPubblication : "+upperPubblication);
Logger.getLogger(loggerName).debug("pub : "+pub);
if (pub.getId().equals(pubblication.getId()) && upperPubblication != null){
Logger.getLogger(loggerName).debug("Before pub.getHorizzontalposition() : "+pub.getHorizzontalposition());
Logger.getLogger(loggerName).debug("Before upperPubblication.getHorizzontalposition() : "+upperPubblication.getHorizzontalposition());
long upperHorizontalPosition = upperPubblication.getHorizzontalposition();
upperPubblication.setHorizzontalposition(pub.getHorizzontalposition());
pub.setHorizzontalposition(upperHorizontalPosition);
Logger.getLogger(loggerName).debug("pub.getHorizzontalposition() : "+pub.getHorizzontalposition());
Logger.getLogger(loggerName).debug("upperPubblication.getHorizzontalposition() : "+upperPubblication.getHorizzontalposition());
session.saveOrUpdate(pub);
session.saveOrUpdate(upperPubblication);
break;
}
upperPubblication = pub;
}//while
tx.commit();
.... .... ....
finally {
if (session != null)session.close();
}
Full stack trace of any exception that occurs:
No errors or exception
Name and version of the database you are using:
MSQL recent , with jtds driver
The generated SQL (show_sql=true):
I don't see any SQL update statements, the follow is my output, look where is the message "move up committed" is witten:
12:29:45,148 DEBUG PubblicationMain:235 - Before pub[id=62].getHorizzontalposition() : 18
12:29:45,148 DEBUG PubblicationMain:236 - Before upperPubblication[id=59].getHorizzontalposition() : 17
12:29:45,148 DEBUG PubblicationMain:241 - pub[id=62].getHorizzontalposition() : 17
12:29:45,148 DEBUG PubblicationMain:242 - upperPubblication[id=59].getHorizzontalposition() : 18
12:29:45,148 DEBUG PubblicationMain:246 - move up committed
Debug level Hibernate log excerpt:
debug level is very verbose, nad almost impossible for me to understand, I put here only the last part:
12:31:13,361 DEBUG SessionImpl:1371 - saveOrUpdate() persistent instance
12:31:13,361 DEBUG Cascades:506 - done processing cascades for: it.rvspm.siscotel.portal.dao.Pubblication
12:31:13,361 DEBUG SessionImpl:2435 - Flushing entities and processing referenced collections
12:31:13,361 DEBUG SessionImpl:2880 - Collection found: [it.rvspm.siscotel.portal.dao.Page.pubblications#69], was: [it.rvspm.siscotel.portal.dao.Page.pubblications#69]
12:31:13,361 DEBUG SessionImpl:2880 - Collection found: [it.rvspm.siscotel.portal.dao.Page.subpages#69], was: [it.rvspm.siscotel.portal.dao.Page.subpages#69]
12:31:13,361 DEBUG SessionImpl:2880 - Collection found: [it.rvspm.siscotel.portal.dao.Content.pubblications#70], was: [it.rvspm.siscotel.portal.dao.Content.pubblications#70]
12:31:13,361 DEBUG SessionImpl:2776 - Processing unreferenced collections
12:31:13,361 DEBUG SessionImpl:2790 - Scheduling collection removes/(re)creates/updates
12:31:13,361 DEBUG SessionImpl:2266 - Flushed: 0 insertions, 0 updates, 0 deletions to 3 objects
12:31:13,361 DEBUG SessionImpl:2271 - Flushed: 0 (re)creations, 0 updates, 0 removals to 3 collections
12:31:13,361 DEBUG Printer:75 - listing entities:
12:31:13,361 DEBUG Printer:82 - it.rvspm.siscotel.portal.dao.Page{created=17 settembre 2004, title=titleTest, owner=null, expire=null, category=null, subpages=[], template=templateTest, modifiedby=null, itemType=Page, id=69, modified=null, pubblications=[Pubblication#71], published=false, createdby=null, name=nameTest, navBarposition=0}
12:31:13,361 DEBUG Printer:82 - it.rvspm.siscotel.portal.dao.Pubblication{created=17 settembre 2004, owner=null, expire=null, category=null, template=null, content=Article#70, itemType=Pubblication, modifiedby=null, horizzontalposition=21, id=71, modified=null, page=Page#69, published=false, verticalposition=0, createdby=null}
12:31:13,361 DEBUG Printer:82 - it.rvspm.siscotel.portal.dao.Article{created=17 settembre 2004, title=null, owner=null, expire=null, template=templateTest, category=null, itemType=Article, modifiedby=null, id=70, modified=null, pubblications=[Pubblication#71], published=false, createdby=null, body=bodyTest}
12:31:13,361 DEBUG SessionImpl:2355 - executing flush
12:31:13,361 DEBUG SessionImpl:2820 - post flush
12:31:13,376 DEBUG SessionImpl:585 - transaction completion
12:31:13,376 DEBUG SessionImpl:573 - closing session
12:31:13,376 DEBUG SessionImpl:3332 - disconnecting session
12:31:13,376 DEBUG SessionImpl:585 - transaction completion
Do you understand where I'm wrong?
Thanks in advance
Stefano
|