Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Getting error if i add a new mapping file to existing config which has 10 files already.
Hibernate version:hibernate 3.0
Mapping documents:
<?xml version="1.0" encoding="utf-8"?>
hibernate.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="hibernate_SessionFactory">
<property name="connection.datasource">weblogic.jdbc.jts.EventLogPool</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<!--
<property name="query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
-->
<!-- Mapping files -->
<mapping resource="EligibilitySummary.hbm.xml"/>
<mapping resource="EligibilityInquiry.hbm.xml"/>
<mapping resource="EligibilityDetails.hbm.xml"/>
<mapping resource="ClaimStatusInquiry.hbm.xml"/>
<mapping resource="ClaimStatusSummary.hbm.xml"/>
<mapping resource="ClaimStatusDetails.hbm.xml"/>
<mapping resource="ProviderLogin.hbm.xml"/>
<mapping resource="ProviderPortalReports.hbm.xml"/>
<mapping resource="CreateUser.hbm.xml"/>
<mapping resource="ModifyUser.hbm.xml"/>
<mapping resource="ProviderManualNotification.hbm.xml"/>
</session-factory>
</hibernate-configuration>
ProviderManualNotification.hbm.xml
<?xml version="1.0"?>
<!-- edited with XMLSpy v2006 sp2 U (
http://www.altova.com) by ven (covansys) -->
<!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.phs.internet.services.eventlogger.dao.ProviderManualNotificationDO" table="PROV_MANUAL_NOTIF_ACK_LOG">
<id name="eventId" column="MANUAL_NOTIFICATION_KEY" type="long">
<generator class="sequence">
<param name="sequence">EVENT_LOG_HEADER_TBL_SEQ</param>
</generator>
</id>
<property name="providerId">
<column name="PROVIDER_ID" not-null="true"/>
</property>
<property name="userType">
<column name="USER_TYPE_CODE" not-null="false"/>
</property>
<property name="parentId">
<column name="PARENT_PROVIDER_ID" not-null="false"/>
</property>
<property name="sessionId">
<column name="SESSION_ID" not-null="false"/>
</property>
<property name="providerFirstName">
<column name="PROVIDER_FIRST_NAME" not-null="false"/>
</property>
<property name="providerFacilityName">
<column name="FACILITY_NAME" not-null="false"/>
</property>
<property name="providerLastName">
<column name="PROVIDER_LAST_NAME" not-null="false"/>
</property>
<property name="providerState">
<column name="PROVIDER_STATE_CODE" not-null="false"/>
</property>
<property name="eventLogDate">
<column name="EVENT_LOG_DATE" not-null="false"/>
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public void persistObjects(ArrayList al) throws RemoteException{
Object identity = null;
Session session = null;
try {
identity = HibernateUtil.createSession();
session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();
for(int i=0;i<al.size();i++){
session.save(al.get(i));
}
tx.commit();
}
catch (Exception he){
he.printStackTrace();
logger.error("Exception in persistObjects(ArrayList al) "+he);
throw new RemoteException();
}
finally {
try{
if (session != null)
HibernateUtil.closeSession(identity);
}catch (Exception he){
logger.error("Exception in persistObjects(ArrayList al) "+he);
throw new RemoteException();
}
}
}
Mapping class
/**
*Modification History
*
*Defect Ref# Version Author Description Date(mm/dd/yyyy)
* 1.0 Sastry Initial Version 09/10/2006
*/
package com.phs.internet.services.eventlogger.dao;
import java.util.Date;
import java.io.Serializable;
/**
* @author kappagun_vs
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class ProviderManualNotificationDO implements Serializable{
private long eventId;
private String providerId;
private String providerFirstName;
private String providerLastName;
private String providerState;
private String parentId;
private String providerFacilityName;
private Date eventLogDate;
private String userType;
private String sessionId;
private String providerManualNotificationInd;
/**
* @return
*/
public long getEventId() {
return eventId;
}
/**
* @return
*/
public Date getEventLogDate() {
return new Date(System.currentTimeMillis());
}
/**
* @return
*/
public String getParentId() {
return parentId;
}
/**
* @return
*/
public String getProviderFacilityName() {
return providerFacilityName;
}
/**
* @return
*/
public String getProviderFirstName() {
return providerFirstName;
}
/**
* @return
*/
public String getProviderId() {
return providerId;
}
/**
* @return
*/
public String getProviderLastName() {
return providerLastName;
}
/**
* @return
*/
public String getProviderState() {
return providerState;
}
/**
* @return
*/
public String getSessionId() {
return sessionId;
}
/**
* @return
*/
public String getUserType() {
return userType;
}
/**
* @param l
*/
public void setEventId(long l) {
eventId = l;
}
/**
* @param date
*/
public void setEventLogDate(Date date) {
eventLogDate = date;
}
/**
* @param string
*/
public void setParentId(String string) {
parentId = string;
}
/**
* @param string
*/
public void setProviderFacilityName(String string) {
providerFacilityName = string;
}
/**
* @param string
*/
public void setProviderFirstName(String string) {
providerFirstName = string;
}
/**
* @param string
*/
public void setProviderId(String string) {
providerId = string;
}
/**
* @param string
*/
public void setProviderLastName(String string) {
providerLastName = string;
}
/**
* @param string
*/
public void setProviderState(String string) {
providerState = string;
}
/**
* @param string
*/
public void setSessionId(String string) {
sessionId = string;
}
/**
* @param string
*/
public void setUserType(String string) {
userType = string;
}
public void setProviderManualNotificationInd(String string) {
providerManualNotificationInd = string;
}
public String getProviderManualNotificationInd() {
return providerManualNotificationInd;
}
}
database table :
CREATE TABLE PROV_MANUAL_NOTIF_ACK_LOG
(
MANUAL_NOTIFICATION_KEY NUMBER NOT NULL,
PROVIDER_ID VARCHAR2(11 BYTE) NOT NULL,
USER_TYPE_CODE VARCHAR2(70 BYTE),
SESSION_ID VARCHAR2(254 BYTE),
PROVIDER_FIRST_NAME VARCHAR2(35 BYTE),
PROVIDER_MIDDLE_NAME VARCHAR2(35 BYTE),
PROVIDER_LAST_NAME VARCHAR2(35 BYTE),
PROVIDER_STATE_CODE VARCHAR2(2 BYTE),
PARENT_PROVIDER_ID VARCHAR2(11 BYTE),
FACILITY_NAME VARCHAR2(70 BYTE),
PROV_MANUAL_NOTIF_IND VARCHAR2(1 BYTE) DEFAULT 'Y',
EVENT_LOG_DATE DATE
)
Full stack trace of any exception that occurs:
Message : Exception in persistObjects(ArrayList al) org.hibernate.MappingException: Unknown entity: com.phs.internet.services.eventlogger.dao.ProviderManualNotificationDO
org.hibernate.MappingException: Unknown entity: com.phs.internet.services.eventlogger.dao.ProviderManualNotificationDO
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1086)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:83)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
at com.phs.internet.services.eventlogger.ejb.EventLoggerServiceBean.persistObjects(EventLoggerServiceBean.java:128)
at com.phs.internet.services.eventlogger.ejb.EventLoggerServiceBean_yoyks2_EOImpl.persistObjects(EventLoggerServiceBean_yoyks2_EOImpl.java:97)
at com.phs.internet.cp.presentation.eventlogger.listeners.LoggerEventListener$1.run(LoggerEventListener.java:80)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:726)
at weblogic.security.Security.runAs(Security.java:61)
at com.phs.internet.cp.presentation.eventlogger.listeners.LoggerEventListener.handleEvent(LoggerEventListener.java:75)
at com.bea.p13n.events.internal.AsynchronousEventHandler$EventRequest.execute(AsynchronousEventHandler.java:145)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:234)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:210)
Name and version of the database you are using:
oracel 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
debug
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html