Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

facing problem in doing application on dynamic class in hibernate

 
anish reddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one provide simple example code on dynamic class in hibernate and names of jars required for it in doing that example ,so that i can execute it properly
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Anish.

What exactly do you mean when you say "on dynamic class in hibernate?" Do you have a little code example that might give us a better understanding of what you're trying to achieve.

My signature links provide a variety of tutorials on how to work with all major aspects of Hibernate and JPA, including setting up a Hibernate environment and doing simple persistence. Perhaps there's something in there that might help you out. Otherwise, maybe a bit more detail about your problem domain might help us help you a bit better.

Regards,

-Cameron McKenzie
 
anish reddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my mapping file
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class entity-name="Customer" table="dynamicclass" >

<tuplizer entity-mode="dynamic-map"
class="CustomMapTuplizerImpl"/>



<id name="id" type="long" column="ID">
<generator class="sequence"/>
</id>
<property name="name" column="name" type="string"/>


</class>
</hibernate-mapping>
// the tuplizer impl

import java.util.Map;

import org.hibernate.mapping.PersistentClass;
import org.hibernate.tuple.entity.EntityMetamodel;

public class CustomMapTuplizerImpl
extends org.hibernate.tuple.entity.DynamicMapEntityTuplizer {

CustomMapTuplizerImpl(EntityMetamodel entityMetamodel, PersistentClass mappedEntity)
{
super(entityMetamodel, mappedEntity);//problem iam facing
// is DynamicMapEntityTuplizer do not have public construtctor that takes argument when // extend and iam passing parameter iam getting compile time error
}

// override the buildInstantiator() method to plug in our custom map...
protected final org.hibernate.tuple.Instantiator buildInstantiator(
org.hibernate.mapping.PersistentClass mappingInfo) {
return new CustomMapInstantiator( mappingInfo );
}

private static final class CustomMapInstantiator
extends org.hibernate.tuple.DynamicMapInstantiator
{

public CustomMapInstantiator(PersistentClass mappingInfo)
{
super(mappingInfo);
}

// override the generateMap() method to return our custom map...

protected final Map generateMap() {
return new CustomMap();
}
}
}
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I get it. You want to map a class that extends Hibernate's DynamicMapEntityTuplizer! Well, I still don't know how to do it.

What's the error message you get when you run it? Can you run normal Hibernate mappings?

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic