Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes org.hibernate.MappingException: Unknown entity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "org.hibernate.MappingException: Unknown entity" Watch "org.hibernate.MappingException: Unknown entity" New topic
Author

org.hibernate.MappingException: Unknown entity

sailaja satya
Greenhorn

Joined: Dec 05, 2008
Posts: 5
Hi,

I am having this error when I run my application..

Caused by: org.hibernate.MappingException: Unknown entity: com.iflex.fcr.entity.channel.Channel
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:514)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:66)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:781)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:774)
at com.iflex.fcr.infra.das.orm.hibernate.HibernateSessionWrapper.load(HibernateSessionWrapper.java:435)
... 21 more

I have checked for the class Channel and it is there.
Can anyone of you please help me to sort this problem?

Thanks in Advance,
Smily
Babu Mehrunnesa
Greenhorn

Joined: Dec 18, 2008
Posts: 9
sailaja satya wrote:Hi,

I am having this error when I run my application..

Caused by: org.hibernate.MappingException: Unknown entity: com.iflex.fcr.entity.channel.Channel
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:514)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:66)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:781)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:774)
at com.iflex.fcr.infra.das.orm.hibernate.HibernateSessionWrapper.load(HibernateSessionWrapper.java:435)
... 21 more

I have checked for the class Channel and it is there.
Can anyone of you please help me to sort this problem?

Thanks in Advance,
Smily


Hi Sailaja,
Could you post your entity classes . So that will have a look and pin-point the problm. OR if you are using any queries on this entity,
Post that also.

Regards
Babu
sailaja satya
Greenhorn

Joined: Dec 05, 2008
Posts: 5
Hi Babu,

Thanks for the response. This is my entity class

package com.iflex.fcr.entity.channel;

import java.util.List;

import com.iflex.fcr.entity.common.IMaintainableEntity;
import com.iflex.fcr.entity.common.MaintainableEntity;
import com.iflex.fcr.infra.enumeration.ReplyMessageType;
import com.iflex.fcr.infra.exception.FatalException;


public class Channel extends MaintainableEntity implements IChannel{

/** @modelguid {12B60A4B-9A14-4840-9648-A3B00C0B9F00} */
private String channelId;

/** @modelguid {FDAED402-E685-47C8-BA8C-5CD345DC0E76} */
private List errorTranslation;

/** @modelguid {5EBCC846-48CF-4DF5-BFFA-E99A38366249} */
private boolean isExceptionAllowed;

/** @modelguid {3BB253ED-43BE-417F-A6D8-2F611EA7778A} */
private boolean isSessionTicketValidationRequired;

/** @modelguid {C3CEF8BB-398F-411E-B85A-E47C94136853} */
private boolean isChannelSuspenseAllowed;

/** @modelguid {CF2593EC-97E8-4BAE-BDF1-AD98AEA5E1F7} */
public void copy(
Channel source) throws FatalException {
if (source.getChannelId() != null) {
this.setChannelId(source.getChannelId());
}

this.setIsExceptionAllowed(source.getIsExceptionAllowed());

this.setVersion(source.getVersion());

if (source.getModificationDate() != null) {
this.setModificationDate(source.getModificationDate());
}

if (source.getStatus() != null) {
this.setStatus(source.getStatus());
}

if (source.getMaintenanceCode() != null) {
this.setMaintenanceCode(source.getMaintenanceCode());
}

if (source.getChecker() != null) {
this.setChecker(source.getChecker());
}

if (source.getMaker() != null) {
this.setMaker(source.getMaker());
}

if (source.getMaintenanceTicket() != null) {
this.setMaintenanceTicket(source.getMaintenanceTicket());
}

if (source.getFieldReferenceNumber() != null) {
this.setFieldReferenceNumber(source.getFieldReferenceNumber());
}
}

/**
* Returns a basic clone of the object
*
* @return IMaintainableEntity
* @see com.iflex.fcr.entity.common.MaintainableEntity#createBasicClone()
* @modelguid {C3CEF8BB-398F-411E-B85A-E47C94136853}
*/
public IMaintainableEntity createBasicClone() {
Channel clone = new Channel();
clone.setChannelId(getChannelId());
clone.setStatus(getStatus());
return clone;

}

/**
* Does an equality check on the present instance and the pass object

* instance.
*
* @param Object arg0
* @return boolean
* @see com.iflex.fcr.entity.common.MaintainableEntity#equals(java.lang.Object)
* @modelguid {3BB253ED-43BE-417F-A6D8-2F611EA7778A}
*/
public boolean equals(
Object arg0) {
if (this == arg0) {
return true;
}
Channel other = (Channel) arg0;
if (other.getChannelId()
.equalsIgnoreCase(getChannelId()) && other.getStatus()
.equals(getStatus())) {
return true;
} else {
return false;
}
}

/**
* Indicates the channel ID
*
* @return channelId
*/
public String getChannelId() {
return channelId;
}

/**
* @return errorTranslation
*/
public List getErrorTranslation() {
return errorTranslation;
}

/**
* Indicates if throwing an exception is allowed for a channel.
*
* @return isExceptionAllowed
*/
public boolean getIsExceptionAllowed() {
return isExceptionAllowed;
}

/**
* Indicates if the session ticket validation is allowed for a channel.
*
* @return isSessionTicketValidationRequired
*/
public boolean getIsSessionTicketValidationRequired() {
return isSessionTicketValidationRequired;
}

/**
* Indicates whether suspense posting is allowed for a channel.
*
* @return isChannelSuspenseAllowed
*/
public boolean getIsChannelSuspenseAllowed() {
return isChannelSuspenseAllowed;
}

/** @modelguid {8BF5FFBF-6DA6-4BAD-89FE-330216449F21} */
public int hashCode() {
int hash = 0;
if (getChannelId() != null) {
hash += getChannelId().hashCode();
}
if (getStatus() != null) {
hash += getStatus().hashCode();
}
return hash == 0
? System.identityHashCode(this) : hash;
}

public String searchAppropiateErrorCode(
ReplyMessageType replyMessage) {
return null;
}

public String searchAppropiateErrorCode(
String errorCode) {
return null;
}

/**
* @param channelId
* @see #getChannelId()
*/
public void setChannelId(
String channelId) {
this.channelId = channelId;
}

/**
* @param errorTranslation
* @see #getErrorTranslation()
*/
public void setErrorTranslation(
List errorTranslation) {
this.errorTranslation = errorTranslation;
}

/**
* @param isExceptionAllowed
* @see #getIsExceptionAllowed()
*/
public void setIsExceptionAllowed(
boolean isExceptionAllowed) {
this.isExceptionAllowed = isExceptionAllowed;
}

/**
* @param isSessionTicketValidationRequired
* @see #getIsSessionTicketValidationRequired()
*/
public void setIsSessionTicketValidationRequired(
boolean isSessionTicketValidationRequired) {
this.isSessionTicketValidationRequired = isSessionTicketValidationRequired;
}

/**
* @param isChannelSuspenseAllowed
* @see #getIsChannelSuspenseAllowed()
*/
public void setIsChannelSuspenseAllowed(
boolean isChannelSuspenseAllowed) {
this.isChannelSuspenseAllowed = isChannelSuspenseAllowed;
}

/**
* This operation generates XML representation of this entity
*
* @param auditBuffer Buffer to hold the XML
* @param enumerateAll Whether all attritbutes should be included in XML
* @modelguid {C0EBF148-F030-4276-A083-F4B0F05E1044}
*/
public void toAuditXml(
StringBuffer auditBuffer,
boolean enumerateAll) {
if (getChannelId() != null) {
auditBuffer.append("<channel-id>")
.append(getChannelId())
.append("</channel-id>");
}
if (enumerateAll) {
auditBuffer.append("<is-exception-allowed>")
.append(getIsExceptionAllowed())
.append("</is-exception-allowed>");
}
if(enumerateAll) {
auditBuffer.append("<is-sessionticket-validation-allowed>")
.append(getIsSessionTicketValidationRequired())
.append("</is-sessionticket-validation-allowed>");
}
if(enumerateAll) {
auditBuffer.append("<is-channelsuspense-allowed>")
.append(getIsChannelSuspenseAllowed())
.append("</is-channelsuspense-allowed>");
}
if (enumerateAll) {
auditBuffer.append("<version>")
.append(getVersion())
.append("</version>");
}
if (enumerateAll && getModificationDate() != null) {
auditBuffer.append("<modification-date>")
.append(getModificationDate())
.append("</modification-date>");
}
if (getStatus() != null) {
auditBuffer.append("<status>")
.append(getStatus())
.append("</status>");
}
if (enumerateAll && getMaintenanceCode() != null) {
auditBuffer.append("<maintenance-code>")
.append(getMaintenanceCode())
.append("</maintenance-code>");
}
if (enumerateAll && getChecker() != null) {
auditBuffer.append("<checker>")
.append(getChecker())
.append("</checker>");
}
if (enumerateAll && getMaker() != null) {
auditBuffer.append("<maker>")
.append(getMaker())
.append("</maker>");
}
if (enumerateAll && getMaintenanceTicket() != null) {
auditBuffer.append("<maintenance-ticket>")
.append(getMaintenanceTicket())
.append("</maintenance-ticket>");
}
if (enumerateAll && getFieldReferenceNumber() != null) {
auditBuffer.append("<field-reference-number>")
.append(getFieldReferenceNumber())
.append("</field-reference-number>");
}
}

public boolean validateAccount(
Object account) {
return false;
}

public boolean validateLimits(
double transactionAmount) {
return false;
}

public boolean validateTransaction(
String taskCode) {
return false;
}

}

There are no queries on this entity.
Babu Mehrunnesa
Greenhorn

Joined: Dec 18, 2008
Posts: 9
Hi Sailaja,
There are few things that would have caused the exception.
1) The entity class should be annotated with @entity and it should implements serializable.
2) Or may be if you are using hibernate context files which lists all your entity classes, might
not contain this entry.

Am exclusively working with annotations. So I don't have much idea on the hbm.xml files.
With annoations if you face any problems, I'l surely help you out.
Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
Hi Sailaja,
Try to use "(code) " tags by replacing () with []. because the code in these tags is easy to understand.
for example.


i am Java +ve Now !
sailaja satya
Greenhorn

Joined: Dec 05, 2008
Posts: 5
Babu,

I am not using annotations at present. However planning to use them in future.
I have checked the config files and all other related files already. Found nothing wrong.

Amir,

Could you please explain me in detail what your suggestion is?


Someone please help in sorting out this issue........
Ruben Matthews
Greenhorn

Joined: Jan 05, 2009
Posts: 26
This always happens to me when I forget to specify the entity in the hibernate config file I use....
sailaja satya
Greenhorn

Joined: Dec 05, 2008
Posts: 5
I have mentioned it in config file. But still the error occurs. I am not able to find the cause.

<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<mapping resource="hbm/api/InsuranceTransferMaintenance.hbm.xml"/>
<mapping resource="hbm/api/TaxGlobalConfiguration.hbm.xml"/>
<mapping resource="hbm/api/Channel.hbm.xml"/>
......................................
.....................................
.....................................
</session-factory>
</hibernate-configuration>
 
 
subject: org.hibernate.MappingException: Unknown entity