I am using ClassMetadata to determine the structure of a hibernate POJO.
I need to determine if a collection is OneToMany or ManyToMany. Where is this information? Can I get to it without using reflection? See my code below.
//Get the class' metadata
ClassMetadata cmd=sf.getClassMetadata(o.getClass());
for(String propertyName:cmd.getPropertyNames()){
if (cmd.getPropertyType(propertyName).isCollectionType() && cmd.??()) //Do something with @ManyToMany collections.
}
All I need is method to tell me if it’s a ManyTo____ relationship. I see getPropertyLaziness(), but that doesn’t always guarantee the type of collection. Any ideas?
It’s not that simple, unfortunatelly. Your best bet to detect this is by checking for particular
CollectionPersisterimplementation: