Caused by: org.hibernate.AnnotationException: Unable to find @AnyMetaDef for an @(ManyTo)Any mapping

Asked on August 28, 2016
Hi I am working with Hibernate @Any and @ManyToAny mapping and I am using @AnyMetaDef at package level. While running my program, I am getting following error. Any clue?

Caused by: org.hibernate.AnnotationException: Unable to find @AnyMetaDef for an @(ManyTo)Any mapping: com.mypackage.StudentInfo.student
at org.hibernate.cfg.BinderHelper.buildAnyValue(
at org.hibernate.cfg.AnnotationBinder.bindAny(
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(
at org.hibernate.cfg.AnnotationBinder.bindClass(
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(
at org.hibernate.cfg.Configuration.secondPassCompile(
at org.hibernate.cfg.Configuration.buildSessionFactory(

Replied on August 28, 2016
As you are configuring @AnyMetaDef at package level, but your program is unable to find it. So you can check if you are configuring package in hibernate configuration.

If you are using hibernate.cfg.xml, you can do it as below.

<mapping package="com.mypackage"/>

com.mypackage should be your package where package resides.

Replied on August 28, 2016
Working, Thanks.

Write Answer

©2024 | Privacy Policy | Contact Us