Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm building the storage subsystem for an application platform. The metamodel will be dynamic (changeable at runtime). I have a metamodel to represent the model structure (complete with pseudo-classes with properties, relationships, hierarchy, etc.). Because the metamodel is dynamic there are no Java classes corresponding to the pseudo-classes in the metamodel.

I know that Hibernate uses a metamodel to map between classes and tables, generating queries based on the class model and populating objects. I'm wondering if there's a way for Hibernate to do this for metaclasses instead of classes, populating proxy objects instead of concrete POJOs.

Basically I want to use my metamodel to define the O/R mapping instead of Java classes. Is this doable with Hibernate? I've kicked around the idea of dynamically generating actual classes at runtime with something like CGLib and mapping those, but I'm hoping there's a better way.

I'm hoping that there's a way to use something like the Hibernate Proxy for this, only not subclassing a POJO, just remaining as a "pure" proxy.

Thoughts?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
361 views
Welcome To Ask or Share your Answers For Others

1 Answer

The sub-folders in https://github.com/hibernate/hibernate-orm/tree/master/hibernate-core/src/test/java/org/hibernate/test/dynamicentity represent 3 ways you might accomplish this. I'd look at the tuplizer2 approach.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...