I am using JPA for persistence and using Hibernate as persistence provider. I want to get XML output from query. This is supported in Hibernate by using following code:
Code:
Session sess = session.getSession(EntityMode.DOM4J);
Element elem = (Element) sess.load(Test.class, 2);
Where this 'elem' is DOM4J element which is XML element. This is working fine when I am using hbm files for storing meta-data, but whem I am using JPA annotation for storing metadata, code is giving following error.
Code:
org.hibernate.HibernateException: No tuplizer found for entity-mode [dom4j]
at org.hibernate.tuple.EntityModeToTuplizerMapping.getTuplizer(EntityModeToTuplizerMapping.java:68)
at org.hibernate.tuple.entity.EntityMetamodel.getTuplizer(EntityMetamodel.java:105)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3455)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:257)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:191)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:795)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788)
What would be the solution for getting the result in XML from JPA entity?