You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kurt Zitze <Ga...@gmx.net> on 2012/10/23 10:54:57 UTC

Hibernate and different entity names for the same class

Hi,

i am using Tapestry 5.3.5 and Hibernate 3.6.10 (Hibernate 4.x is not possible to use).

I have a class A and i am mapping this class multiple times with different Hibernate entity names A1 and A2, like this:

A.java

class A { ... }

A1.hbm.xml

<hibernate-mapping>
  <class name="my.package.A" entity-name="A1">
    ...
  </class>
</hibernate-mapping>

A2.hbm.xml

<hibernate-mapping>
  <class name="my.package.A" entity-name="A2">
    ...
  </class>
</hibernate-mapping>

While doing so, tapestry comes up with the following error message:

java.lang.RuntimeException: Exception constructing service 'ValueEncoderSource': Error invoking service contribution method org.apache.tapestry5.hibernate.HibernateModule.contributeValueEncoderSource(MappedConfiguration, boolean, HibernateSessionSource, Session, TypeCoercer, PropertyAccess, LoggerSource): Service contribution (to service 'ValueEncoderSource') conflicts with existing contribution (by org.apache.tapestry5.hibernate.HibernateModule.contributeValueEncoderSource(MappedConfiguration, boolean, HibernateSessionSource, Session, TypeCoercer, PropertyAccess, LoggerSource) (at HibernateModule.java:87)).

I think i know why this is happening. It is because Tapestry wants to register value encoders for mapped entity A1 and A2. Since both entities are based on the same class, Tapestry registers value encoders for the same class twice.

I know that i can avoid this error by derriving (empty) sub classes A1 and A2 an mapping these instead. 

But my question is of course, how can i map a single class multiple times with different entity names?

Best regards, garz

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org