-->
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.  [ 1 post ] 
Author Message
 Post subject: Exception in thread "main" org.hibernate.MappingException: U
PostPosted: Sun Mar 24, 2013 7:28 am 
Newbie

Joined: Sun Mar 24, 2013 7:12 am
Posts: 1
THIS is my source code.

how can iresolve this

public class ChequePayment extends Payment
{
private String chequeType;


public String getChequeType()
{
return chequeType;
}

public void setChequeType(String chequeType)
{
this.chequeType = chequeType;
}
}



public class CreditCardPayment extends Payment
{
private String cardType;

public String getCardType()
{
return cardType;
}

public void setCardType(String cardType)
{
this.cardType = cardType;
}

}


public class ChequePayment extends Payment
{
private String chequeType;


public String getChequeType()
{
return chequeType;
}

public void setChequeType(String chequeType)
{
this.chequeType = chequeType;
}
}


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>

<session-factory>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="connection.username">scott</property>
<property name="connection.password">tiger</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="myeclipse.connection.profile">hari</property>

</session-factory>

</hibernate-configuration>

import org.hibernate.*;
import org.hibernate.cfg.*;

public class InsertClient
{
public static void main(String[] args)
{
Configuration cfg=new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory factory=cfg.buildSessionFactory();
Session session=factory.openSession();

CreditCardPayment ccp=new CreditCardPayment();
ccp.setPaymentId(101);
ccp.setAmount(5000);
ccp.setPaymentDate(new java.util.Date());
ccp.setCardType("VISA");

ChequePayment cp=new ChequePayment();
cp.setPaymentId(102);
cp.setAmount(8000);
cp.setPaymentDate(new java.util.Date());
cp.setChequeType("ORDER");

Transaction tx=session.beginTransaction();
session.save(ccp);
session.save(cp);
System.out.println("Objects saved successfully.....!!");
tx.commit();
session.close();
factory.close();
}
}


my error


log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.MappingException: Unknown entity: CreditCardPayment
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:597)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1339)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:536)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:524)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:520)
at InsertClient.main(InsertClient.java:26)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.