-->
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.  [ 4 posts ] 
Author Message
 Post subject: 3.0b1 throws exception on simple delete
PostPosted: Tue Jan 11, 2005 5:11 am 
Newbie

Joined: Fri Sep 17, 2004 3:07 pm
Posts: 14
This deletion code works fine in v2. Had the same problem in alpha, waited until b to report. Bug or misconfiguration ?


Hibernate version: 3.0beta1

Mapping documents:
<?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>


<class
name="fi.documenta.dng.domain.doc.DocumentEntity"
table="DOCUMENT">
<id
name="id"
column="ID">
<generator class="increment"/>
</id>

<property
name="creationDate"
column="CREATION_DATE"/>

<property
name="documentName"
column="DOCUMENT_NAME"/>

<set name="documentVersions" table="DOCUMENTVERSION" inverse="true" cascade="all" lazy="true">
<key column="DOCUMENT_ID" />
<one-to-many class="fi.documenta.dng.domain.doc.DocumentVersionEntity" />
</set>

<set name="documentGroups" table="DocumentReference" inverse="true" cascade="all" lazy="true">
<key column="referred_document_id" />
<one-to-many class="fi.documenta.dng.domain.doc.DocumentReferenceEntity" />
</set>

<set name="accessControlList" table="DOCUMENT_ACL_ENTRY" inverse="true" cascade="all" lazy="false">
<key column="document_id" />
<one-to-many class="fi.documenta.dng.domain.doc.sec.DocumentAclEntryEntity" />
</set>

<many-to-one name="latestVersion" class="fi.documenta.dng.domain.doc.DocumentVersionEntity" column="LATEST_DOC_VERSION_ID" cascade="none"/>
<many-to-one name="latestReadyVersion" class="fi.documenta.dng.domain.doc.DocumentVersionEntity" column="LATEST_READY_VERSION_ID" cascade="none"/>
<filter name="docAuthFilter" condition="exists(select * from DOCUMENT_ACL_ENTRY acl, DOCUMENT_PERMISSION p where acl.document_id=id and acl.id=p.acl_id and :permissionType=p.permission_type and acl.immutable_principal_name in (:principal1, :principal2, :principal3, :principal4, :principal5))"/>
</class>
<filter-def name="docAuthFilter">
<filter-param name="principal1" type="string"/>
<filter-param name="principal2" type="string"/>
<filter-param name="principal3" type="string"/>
<filter-param name="principal4" type="string"/>
<filter-param name="principal5" type="string"/>
<filter-param name="permissionType" type="string"/>
</filter-def>

</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public void deleteDocument(Long docId) throws Exception {
ses().delete("from DocumentEntity as de where de.id=" + docId);
}

Full stack trace of any exception that occurs:
2005-01-11 10:38:01,215 DEBUG [fi.documenta.dng.domain.doc.DocumentSFCProxyImpl] Entering method deleteDocument(java.lang.Long 4).
2005-01-11 10:38:01,215 DEBUG [org.hibernate.event.DefaultCopyEventListener] deleting a transient instance
2005-01-11 10:38:01,215 DEBUG [org.hibernate.impl.SessionImpl] closing session
2005-01-11 10:38:01,225 ERROR [fi.documenta.dng.mvc.doc.FolderContentsAction] fi.documenta.fwk.exception.BackEndException: org.hibernate.MappingException: Unknown entity: java.lang.String
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:444)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1259)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1264)
at org.hibernate.event.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:56)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:629)
at fi.documenta.dng.domain.doc.DocumentSFCProxyImpl.deleteDocument(DocumentSFCProxyImpl.java:333)


Name and version of the database you are using:
MySQL 4.1.7
The generated SQL (show_sql=true):
None generated before exception.
Debug level Hibernate log excerpt:
see above


Top
 Profile  
 
 Post subject: Re: 3.0b1 throws exception on simple delete
PostPosted: Tue Jan 11, 2005 5:50 am 
Newbie

Joined: Fri Sep 17, 2004 3:07 pm
Posts: 14
So it is a bug. The delete(String query) API has changed to delete(Object o) BUT the manual still says:

"You may also delete many objects at once by passing a Hibernate query string to delete()."

Working around in order not to change my API nor to serialize the whole object when only the id is needed:

Query q=ses().createQuery("from DocumentEntity as de where de.id=" + docId);
ses().delete(q.list().get(0));

Works.

//markku


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 6:52 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It will be done in the next releases to conform with the EJB3 API

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 9:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can also just use org.hibernate.classic.Session


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.