Hi Emmanuel,
Thanks for your reply. I removed the @mappedSuperclass from the class annotations and the @embedded on the "blob" attributes.
The good thing is that now my database is created without the mapping exception. Unfortunately, it brings another problem:
The reason I had used the @mappedSuperclass was because I wanted my subclass to "inherit" the properties of the embeddable object.
To better understand my need here are the entities I would like to create:
Article
-------
id: string
ArticleLocalization
---------------------
binaryContent: blob
representation: blob
ItemArticle (extends Article)
-------------
...(some attributes)
ItemArticleLocalization (extends ArticleLocalization)
--------------------------
...(other localized attributes)
ArticleLocalization is a mapped from article and is therefore an "embeddable" element.
ItemArticleLocalization is mapped from ItemArticle and is also an "embeddable" element.
Ideally, I would like the attributes not to be repeated in the ItemArticleLocalization table but I don't know how to do this. Otherwise, I could live with the fact of having the attributes in both the localized tables.
Right now, when I try to save any entity without the mappedsuperclass I get the following error:
Code:
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.mdarad.global.dao.HibernateDAOFactoryBase.createDAO(HibernateDAOFactoryBase.java:678)
at org.mdarad.global.dao.HibernateDAOFactoryBase.getCommentDAO(HibernateDAOFactoryBase.java:568)
at org.mdarad.samples.totaltest.facades.CommentBusinessObjectFacadeBase.getInstanceDAO(CommentBusinessObjectFacadeBase.java:39)
at org.mdarad.samples.totaltest.facades.CommentBusinessObjectFacadeBase.saveComment(CommentBusinessObjectFacadeBase.java:66)
at org.mdarad.samples.totaltest.unittests.AbstractCommentTestCase.createMinimalComment(AbstractCommentTestCase.java:20)
at org.mdarad.samples.totaltest.unittests.CommentTestCase.testCreateMinimal(CommentTestCase.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.hibernate.persister.collection.AbstractCollectionPersister.generateSelectSizeString(AbstractCollectionPersister.java:867)
at org.hibernate.persister.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:475)
at org.hibernate.persister.collection.BasicCollectionPersister.<init>(BasicCollectionPersister.java:50)
at org.hibernate.persister.PersisterFactory.createCollectionPersister(PersisterFactory.java:72)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:250)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.mdarad.framework.business.dao.HibernateDAO.<clinit>(HibernateDAO.java:30)
... 28 more
I used to be able to do this without the annotations (repeated attributes though) but can't seem to accomplish it with the annotations.
Your help would be greatly appreciated.
Thanks again,
François