Hi,
I'm having a problem using a dynamic-component mapping.
If I use hibernate directly, everything works fine. If I used through EntityManager, I get an exception when loading the configuration:
Exception in thread "main" java.lang.IllegalArgumentException: Cannot determine java-type from given member [null]
Any idea??? I can upload the full sample if needed.
thanks in advance
Tagut
pd: here is the full detail of configuration and clases.
=============================
I'm working with this versions:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.5.Final</version>
</dependency>
Exception in thread "main" java.lang.IllegalArgumentException: Cannot determine java-type from given member [null]
at org.hibernate.ejb.metamodel.AttributeFactory$BaseAttributeMetadata.<init>(AttributeFactory.java:608)
at org.hibernate.ejb.metamodel.AttributeFactory$SingularAttributeMetadataImpl.<init>(AttributeFactory.java:696)
at org.hibernate.ejb.metamodel.AttributeFactory$SingularAttributeMetadataImpl.<init>(AttributeFactory.java:686)
at org.hibernate.ejb.metamodel.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:559)
at org.hibernate.ejb.metamodel.AttributeFactory.buildAttribute(AttributeFactory.java:93)
at org.hibernate.ejb.metamodel.AttributeFactory.getMetaModelType(AttributeFactory.java:225)
at org.hibernate.ejb.metamodel.AttributeFactory.buildAttribute(AttributeFactory.java:102)
at org.hibernate.ejb.metamodel.MetadataContext.wrapUp(MetadataContext.java:187)
at org.hibernate.ejb.metamodel.MetamodelImpl.buildMetamodel(MetamodelImpl.java:66)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at test.Test.main(Test.java:24)
This is my mapping file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="test">
<class name="TestEntity" table="TestEntity">
<id name="id" column="ID"/>
<dynamic-component name="mapa">
<property name="V_V1" column="V_V1" type="java.lang.String"/>
</dynamic-component>
<property name="status" column="STATUS"/>
</class>
</hibernate-mapping>
This is my configuration file:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="connection.username">OBPMENGINE</property>
<property name="connection.password">OBPMENGINE</property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.Oracle9iDialect</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="TestEntity.hbm.xml"/>
</session-factory>
</hibernate-configuration>
And this is my persistence file:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/ ... ce_2_0.xsd"
version="2.0">
<persistence-unit name="nt-bpm-bi" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/>
<property name="hibernate.archive.autodetection" value="none"/>
</properties>
</persistence-unit>
</persistence>
======
This is my entity:
package test;
import java.util.Map;
public class TestEntity {
private Integer id;
private String status;
private Map mapa;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Map getMapa() {
return mapa;
}
public void setMapa(Map mapa) {
this.mapa = mapa;
}
}
And my test:
package test;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class Test {
public static final void main(String args[]) throws Exception {
// This works fine.
// A SessionFactory is set up once for an application
// SessionFactory sessionFactory = new Configuration()
// .configure()
// .buildSessionFactory();
// Session s = sessionFactory.openSession();
// This fails.
EntityManagerFactory emf = Persistence.createEntityManagerFactory("nt-bpm-bi");
}
}