-->
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: migration from 3.5 to 4.3.5 - 'Unknown entity' error problem
PostPosted: Tue Oct 07, 2014 3:39 am 
Newbie

Joined: Sat Sep 27, 2014 12:18 pm
Posts: 1
Migration required from 3.5 (notably hibernate3.jar) to 4.3.5. Application is simple POJOs annotated with basic JAXB (@XMLRootElement, etc). Also, simple hbm.xml and cfg.xml. Use by an unremarkable persister class to a PostgreSQL DB. Repaired compile errors such as hibernate.org DTD location.

Error for *all* tables is "Unknown entity". Would appreciate a hand. Many thanks in advance. -mb

Hibernate .jar deltas:
PREVIOUS:
antlr-2.7.6.jar
c3p0-0.9.1.jar
cglib-2.2.jar
commons-collections-3.1.jar
dom4j-1.6.1.jar
hibernate-jpa-2.0-api-1.0.0.Final.jar
hibernate-validator-4.0.2.GA.jar
hibernate3.jar
javassist-3.9.0.GA.jar
jta-1.1.jar
oscache-2.1.jar
proxool-0.8.3.jar
slf4j-api-1.5.11.jar
slf4j-log4j12-1.5.11.jar
swarmcache-1.0RC2.jar

NEW:
antlr-2.7.7.jar
c3p0-0.9.2.1.jar
hibernate-c3p0-4.3.5.Final.jar
mchange-commons-java-0.2.3.4.jar
commons-collections4-4.0.jar
hibernate-commons-annotations-4.0.4.Final
hibernate-core-4.3.5.Final.jar
jandex-1.1.0.Final.jar
jboss-logging-3.1.3.GA.jar
jboss-logging-annotations-1.2.0.Beta1.jar
jboss-transaction-api_1.2_spec-1.0.0.Final.jar
hibernate-envers-4.3.5.Final.jar
hibernate-entitymanager-4.3.5.Final.jar
dom4j-1.6.1.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
hibernate/hibernate-validator-5.1.1.Final.jar
hibernate-testing-4.3.5.Final.jar
jbosscache-core.jar
jboss-cache.jar
ehcache-core-2.4.3.jar
hibernate-ehcache-4.3.5.Final.jar
hibernate-infinispan-4.3.5.Final.jar
infinispan-commons-6.0.0.Final.jar
infinispan-core-6.0.0.Final.jar
javassist-3.18.1-GA.jar
jta-1.1.jar
oscache-2.4.1.jar

CONFIGURATION FILE:

<?xml version='1.0' encoding='utf-8'?>
<!--
~ Copyright (c) 2006 - 2014 Make Sence Florida Inc.
-->

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>

<session-factory>

<property name="hibernate.ejb.naming_strategy">
org.hibernate.cfg.DefaultComponentSafeNamingStrategy
</property>

<property name="hibernate.current_session_context_class">thread</property>

<mapping resource="com/project/modules/security/types/SecurityPrincipalEntity.hbm.xml"/>

</session-factory>
</hibernate-configuration>

POJO:

package com.project.modules.security.types;

/*
* Copyright (c) 2006 - 2014 Make Sence Florida Inc.
*/

import com.project.modules.persist.entity.EntityBase;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

@XmlRootElement(name = "principal")
@XmlAccessorType(XmlAccessType.FIELD)
public class SecurityPrincipalEntity extends EntityBase<Long> {

private static final long serialVersionUID = 130656661920374675L;

@XmlAttribute(required = false)
private Long key;

@XmlTransient
private Long version;

@XmlElement(required = true, name = "user_name")
private String user_name;

@XmlElement(required = true, name = "user_password")
private String user_password;

public SecurityPrincipalEntity() {
}

public SecurityPrincipalEntity(String target) {
this.user_name = target;
}

public Long getVersion() {
return version;
}

public String getUser_name() {
return user_name;
}

public String getUser_password() {
return user_password;
}

public Long getKey() {
return key;
}

public void writeTo(DataOutputStream out) throws IOException {
}

public void readFrom(DataInputStream in)
throws IOException, IllegalAccessException, InstantiationException {
}
}

HBM.XML:

<?xml version="1.0"?>
<!--
~ Copyright (c) 2006 - 2014 Make Sence Florida Inc.
-->

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.project.modules.security.types">

<class name="com.project.modules.security.types.SecurityPrincipalEntity"
table="security_principal">

<id access="field" name="key" type="long">
<generator class="identity"/>
</id>

<version access="field" name="version" type="long"/>

<property access="field" name="user_name" type="string">
<column name="user_name" length="2048"/>
</property>

<property access="field" name="user_password" type="string">
<column name="user_password" length="2048"/>
</property>

</class>

</hibernate-mapping>

PERSISTER CLASS:

package com.project.modules.security.types;

import com.project.modules.foundation.topology.datasource.DataSourceType;
import com.project.modules.persist.Persist;
import com.project.modules.persist.PersistException;
import com.project.modules.persist.entity.EntityPersisterBase;
import org.hibernate.Query;

/*
* Copyright (c) 2006 - 2014 Make Sence Florida Inc.
*/

public class PrincipalPersister extends EntityPersisterBase<Long, SecurityPrincipalEntity> {

private static final long serialVersionUID = -49958433413782923L;

@Override
public DataSourceType getType() {
return DataSourceType.Discovery;
}

@Override
protected SecurityPrincipalEntity createNewPersistedClass() throws PersistException {
try {
return new SecurityPrincipalEntity();
} catch (Throwable e) {
throw new PersistException(e);
}
}

@Override
protected Query getDeleteAllEntitiesQuery() {
return Persist.session(getType()).createQuery("delete from SecurityPrincipalEntity ");
}

@Override
protected SecurityPrincipalEntity fetchByKeyFromDb(Long key) throws PersistException {
return (SecurityPrincipalEntity) Persist.session(getType())
.get(SecurityPrincipalEntity.class, key);
}


@Override
protected Query getFetchBatchQuery() {
return Persist.session(getType())
.createQuery("select c from SecurityPrincipalEntity c order by c.key");
}

@Override
protected Query getFetchAllQuery() throws PersistException {
return Persist.session(getType()).createQuery("select e from SecurityPrincipalEntity e");
}

@Override
protected Query getCountAllEntitiesQuery() {
return Persist.session(getType())
.createQuery("select count(c) from SecurityPrincipalEntity c");
}

@Override
protected Class<?>[] getTypes() {
return new Class<?>[]{SecurityPrincipalEntity.class};
}

@Override
protected Query deleteEntityByKeyQuery() {
return Persist.session(getType())
.createQuery("delete from SecurityPrincipalEntity r where r.key = ?");
}

@Override
protected String getPersistName() {
return "principal";
}

}

END SUBMISSION END SUBMISSION END SUBMISSION


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.