-->
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.  [ 5 posts ] 
Author Message
 Post subject: Subclassing and "net.sf.hibernate.MappingException"
PostPosted: Fri Dec 12, 2003 4:04 pm 
Newbie

Joined: Fri Dec 12, 2003 4:00 pm
Posts: 4
Please help!!!

First, I am using Hibernate 2.0.3 and Spring.

I have a interface called PaymentType which has 2 implementing classes- CreditCardPaymentType and EmailPaymentType. I am able to persist new PaymentTypes without issues; however, when associating a PaymentType to another object (Registration), I receive the following exception:

No persister for: com.demandsolutions.merovingian.payment.entity.PaymentType; nested exception is: net.sf.hibernate.MappingException: No persister for: com.demandsolutions.merovingian.payment.entity.PaymentType

Registration.java
------------------------
public class Registration extends BaseEntityObject {
private PaymentType paymentType;

// other variables and methods......

// Hibernate Mappings declared in supplementary file!
public PaymentType getPaymentType() {
return this.paymentType;
}

public void setPaymentType(PaymentType paymentType) {
this.paymentType = paymentType;
}

}

Registration.hbm.xml
--------------------------------
<hibernate-mapping>
<class name="com.demandsolutions.merovingian.conference.entity.Registration" table="registration" dynamic-update="true" dynamic-insert="true" >
// other declarations
<any name="paymentType" meta-type="class" id-type="long">
<column name="PAYMENT_TYPE_CLASS"/>
<column name="PAYMENT_TYPE_ID"/>
</any>
</hibernate-mapping>



Any and all help is appreciated! Thanks in advance!



Cheers,
matthew


Top
 Profile  
 
 Post subject: Mapping File For My Problem
PostPosted: Sat Dec 13, 2003 12:25 am 
Newbie

Joined: Fri Dec 12, 2003 4:00 pm
Posts: 4
I am posting my mapping files in hopes that someone can help me find my problem.

Once again, PaymentType is an interface. CreditCardPaymentType is an abstract class extended by multiple class. They are marked as subclasses.

Thanks for the help!


CreditCardPaymentType.hbm.xml
--------------------------------------
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="com.demandsolutions.merovingian.payment.entity.CreditCardPaymentType"
table="credit_card_payment_type" dynamic-update="true" dynamic-insert="true">

<id name="id" column="id" type="long" unsaved-value="0">
<generator class="native"></generator>
</id>

<discriminator column="credit_card" type="string"/>

<property name="nameOnCard" type="java.lang.String" update="true"
insert="true" column="name_on_card" not-null="true"/>

<property name="cardNumber" type="java.lang.String" update="true"
insert="true" column="card_number" not-null="true"/>

<property name="expirationDate" type="java.lang.String" update="true"
insert="true" column="expiration_date" not-null="true"/>

<many-to-one name="user" class="com.metissian.security.user.entity.User" cascade="none"
outer-join="auto" update="true" insert="true" column="user_id" not-null="true"/>

<property name="creationDate" type="java.util.Date" update="true"
insert="true" column="creation_date" not-null="true"/>

<property name="modificationDate" type="java.util.Date" update="true"
insert="true" column="modification_date" not-null="true"/>

<subclass name="com.demandsolutions.merovingian.payment.entity.AmericanExpressPaymentType"
dynamic-update="true" dynamic-insert="true">
</subclass>

<subclass name="com.demandsolutions.merovingian.payment.entity.DiscoverPaymentType"
dynamic-update="true" dynamic-insert="true">
</subclass>

<subclass name="com.demandsolutions.merovingian.payment.entity.MastercardPaymentType"
dynamic-update="true" dynamic-insert="true">
</subclass>

<subclass name="com.demandsolutions.merovingian.payment.entity.VisaPaymentType"
dynamic-update="true" dynamic-insert="true">
</subclass>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 13, 2003 12:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Yes, but how does the exception actually occur?? Java code? FULL stack trace?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 13, 2003 1:30 am 
Newbie

Joined: Fri Dec 12, 2003 4:00 pm
Posts: 4
OK. It's now absolutely obvious I should not have asked this question on 2 hours of sleep over a period of 40 hours ;)

Anyways, this problem is occuring when I tried to load a PaymentType object. I am calling:
this.getHibernateTemplate().load(clazz, serializable);
where clazz = PaymentType.class & serializable = id of paymentType.

I believe this has to do with not having a mapping file for PaymentType.class. Am I right?


Stack Trace
---------------
net.sf.hibernate.MappingException: No persister for: com.demandsolutions.merovingian.payment.entity.PaymentType
net.sf.hibernate.MappingException: No persister for: com.demandsolutions.merovingian.payment.entity.PaymentType
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:420)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2302)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1754)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1688)
at org.springframework.orm.hibernate.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:181)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:147)
at org.springframework.orm.hibernate.HibernateTemplate.load(HibernateTemplate.java:179)
at com.metissian.persistence.hibernate.HibernatePersister.find(HibernatePersister.java:22)
at com.metissian.persistence.hibernate.HibernatePersister$$EnhancedByCGLIB$$10$$ProxiedByCGLIB$$940.invoke(<generated>)
at org.springframework.aop.framework.CglibMethodInvocation.invokeJoinpoint(CglibMethodInvocation.java:44)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:204)
at com.metissian.persistence.dao.interceptor.AuditableInterceptor.invoke(AuditableInterceptor.java:38)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:226)
at org.springframework.orm.hibernate.HibernateInterceptor.invoke(HibernateInterceptor.java:85)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:226)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:226)
at org.springframework.aop.framework.Cglib1AopProxy.intercept(Cglib1AopProxy.java:143)
at com.metissian.persistence.hibernate.HibernatePersister$$EnhancedByCGLIB$$10.find(<generated>)
at com.metissian.persistence.dao.provider.hibernate.BaseHibernateEntityDao.find(BaseHibernateEntityDao.java:18)
at com.demandsolutions.merovingian.payment.DefaultPaymentManager.getPaymentType(DefaultPaymentManager.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:62)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:231)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:204)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:226)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:145)
at $Proxy8.getPaymentType(Unknown Source)
at com.demandsolutions.merovingian.conference.actions.RegistrationAction.checkPayment(RegistrationAction.java:204)
at com.demandsolutions.merovingian.conference.actions.RegistrationAction.execute(RegistrationAction.java:128)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:172)
at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:37)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:169)
at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:37)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:169)
at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:37)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:169)
at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:37)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:169)
at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:37)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:169)
at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116)
at com.opensymphony.webwork.dispatcher.ServletDispatcher.serviceAction(ServletDispatcher.java:182)
at com.opensymphony.webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:342)
at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:129)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:61)
at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:334)
at com.atlassian.seraph.filter.SecurityFilter.doFilter(SecurityFilter.java:161)
at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:334)
at com.atlassian.seraph.filter.LoginFilter.doFilter(LoginFilter.java:181)
at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:334)
at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:83)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:39)
at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:334)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:286)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1723)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:514)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1673)
at org.mortbay.http.HttpServer.service(HttpServer.java:879)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:783)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:945)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:800)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:201)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:454)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 13, 2003 1:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Correct. So use a query:


Code:
session.createQuery("from PaymentType pt where pt.id = ?")
    .setLong(id)
    .uniqueResult();


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