-->
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: Unknown entity: java.lang.Long
PostPosted: Thu Aug 21, 2008 12:11 pm 
Newbie

Joined: Thu Aug 14, 2008 1:57 pm
Posts: 1
Every time I try to delete my persistent object I get this exception:

org.hibernate.MappingException: Unknown entity: java.lang.Long

I am using the spring open session in view filter. I am trying to delete an object after the session that retrieved it has been closed. However I am trying to reassociate the object with a new session in my dao delete method by calling getHibernateTemplate().update(entity);

Here is my delete method and my mapping file and my exception. Could someone please help? Thanks
Code:
   public void delete(final T entity)
   {
      getHibernateTemplate().update(entity);
      getHibernateTemplate().delete(entity.getEntityId());
   }

Code:
<?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="com.redi.robojot.model.impl.Location" table="locations">
      <id name="entityId" column="entityId" type="long">
         <generator class="native"/>
      </id>
      <property name="name"/>
      <property name="description"/>
      <property name="street"/>
      <property name="city"/>
      <property name="state"/>
      <property name="zip"/>
      <property name="lattitude"/>
      <property name="longitude"/>
      <set name="answers" table="answer_location">
         <key column="locationId"/>
      <many-to-many column="answerId" class="com.redi.robojot.model.impl.AnswerImpl"/>
      </set>
   </class>
</hibernate-mapping>


Code:
org.hibernate.MappingException: Unknown entity: java.lang.Long     at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)     at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)     at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:78)     at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:52)     at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:766)     at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)     at org.springframework.orm.hibernate3.HibernateTemplate$25.doInHibernate(HibernateTemplate.java:767)     at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)     at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:761)     at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:757)     at com.redi.dao.HibernateDAO.delete(HibernateDAO.java:169)     at com.redi.robojot.ui.GoogleMapPanel$1$1.onClick(GoogleMapPanel.java:114)     at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:214)     at java.lang.reflect.Method.invoke(Unknown Source)     at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:183)     at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)     at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)     at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1166)     at org.apache.wicket.RequestCycle.step(RequestCycle.java:1243)     at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1330)     at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)     at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:358)     at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)     at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)     at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:856)     at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:565)     at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)     at java.lang.Thread.run(Unknown Source)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 21, 2008 2:25 pm 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
You should delete your persistent object, not it's id.
Try this:
Code:
getHibernateTemplate().delete(entity);


Christophe


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.