You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nomen Nomanum <ge...@outlook.com> on 2013/06/18 03:42:50 UTC
Resolving PersistentClass instances mapping to the same entity
Hi. :)
I have following case:
Article
- -
- -
Fruits Vegetables
Fruits and Vegetables inherits Article, and both Fruits and Vegetables have same DiscriminatorValue. Now when I try to do some ValueEncoder magic like in following
public class ArticleEncoder implements ValueEncoder< Article>, ValueEncoderFactory< Article> {
private LogicDAO logicDAO;
@Override
public String toClient(final Article v) {
return String.valueOf(v.getName());
}
@Override
public Artikal toValue(String string) {
Article result = new Article();
result = logicDAO.listSpecificArticle(string);
return result;
}
@Override
public ValueEncoder< Article> create(Class< Article> type) {
return this;
}
}
I get following
HTTP Status 500 - 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 com.google.tapestrySection.teamAlpha.services.AppModule.contributeValueEncoderSource(MappedConfiguration, LogicDAO) (at AppModule.java:1264)).
Anyone knows how to hack this issue here? :)
Re: Resolving PersistentClass instances mapping to the same entity
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, Jun 18, 2013 at 9:11 AM, Nomen Nomanum <ge...@outlook.com>wrote:
> Great proposal, @Lava! :)
> But for that method MappedConfiguration.override(...) I will have to
> include TypeCoercion so that Tapestry exactly knows how to handle with the
> following String --> long ( my entity Article has it's @Id positioned on id
> field, so HibernateModule.contributeValueEncoderSource()
> catches itself on that field ). Any comment on this flow?
>
The fact you're changing MappedConfiguration.add() to override() doesn't
create any additional requirements. I don't think you'll need to include a
TypeCoercion for String -> long, because it's probably there already, I
just couldn't check.
>
> > Date: Tue, 18 Jun 2013 10:01:05 +0100
> > Subject: RE: Resolving PersistentClass instances mapping to the same
> entity
> > From: lance.java@googlemail.com
> > To: users@tapestry.apache.org
> >
> > Can you guarantee that name is unique and will never change?
> >
> > If not, you might want to concatenate name and id in your ValueEncoder
> and
> > ignore the name in the lookup so that old bookmarks and duplicate names
> are
> > not broken.
> >
> > As Thiago suggested, use MappedConfiguration.override(...) to override
> the
> > default encoder contributed by tapestry-hibernate.
>
>
--
Thiago
RE: Resolving PersistentClass instances mapping to the same entity
Posted by Nomen Nomanum <ge...@outlook.com>.
Great proposal, @Lava! :)
But for that method MappedConfiguration.override(...) I will have to include TypeCoercion so that Tapestry exactly knows how to handle with the following String --> long ( my entity Article has it's @Id positioned on id field, so HibernateModule.contributeValueEncoderSource()
catches itself on that field ). Any comment on this flow?
> Date: Tue, 18 Jun 2013 10:01:05 +0100
> Subject: RE: Resolving PersistentClass instances mapping to the same entity
> From: lance.java@googlemail.com
> To: users@tapestry.apache.org
>
> Can you guarantee that name is unique and will never change?
>
> If not, you might want to concatenate name and id in your ValueEncoder and
> ignore the name in the lookup so that old bookmarks and duplicate names are
> not broken.
>
> As Thiago suggested, use MappedConfiguration.override(...) to override the
> default encoder contributed by tapestry-hibernate.
RE: Resolving PersistentClass instances mapping to the same entity
Posted by Lance Java <la...@googlemail.com>.
Can you guarantee that name is unique and will never change?
If not, you might want to concatenate name and id in your ValueEncoder and
ignore the name in the lookup so that old bookmarks and duplicate names are
not broken.
As Thiago suggested, use MappedConfiguration.override(...) to override the
default encoder contributed by tapestry-hibernate.
RE: Resolving PersistentClass instances mapping to the same entity
Posted by Nomen Nomanum <ge...@outlook.com>.
I would like to have on @PageActivationContext to return name() instead of id(). That's the only reason for my ValueEncoder service. Do you happen to know some other workaround this issue?
> Date: Mon, 17 Jun 2013 23:01:25 -0300
> Subject: Re: Resolving PersistentClass instances mapping to the same entity
> From: thiagohp@gmail.com
> To: users@tapestry.apache.org
>
> As the exception says, both HibernateModule.contributeValueEncoderSource()
> and AppModule.contributeValueEncoderSource() are contributing a
> ValueEncoder for a given type and that's forbidden. Do you really need to
> provide your own ValueEncoders? Doesn't the Tapestry-Hibernate provided
> ones suit your needs? If you don need your own ValueEncoders, you can
> contribute them using the MappedConfiguration.override() method instead of
> add(). Otherwise, just don't provide your own ones.
>
>
> On Mon, Jun 17, 2013 at 10:42 PM, Nomen Nomanum <ge...@outlook.com>wrote:
>
> > Hi. :)
> > I have following case:
> > Article
> > - -
> > - -
> > Fruits Vegetables
> >
> >
> > Fruits and Vegetables inherits Article, and both Fruits and Vegetables
> > have same DiscriminatorValue. Now when I try to do some ValueEncoder magic
> > like in following
> > public class ArticleEncoder implements ValueEncoder< Article>,
> > ValueEncoderFactory< Article> {
> >
> > private LogicDAO logicDAO;
> >
> > @Override
> > public String toClient(final Article v) {
> > return String.valueOf(v.getName());
> > }
> >
> > @Override
> > public Artikal toValue(String string) {
> > Article result = new Article();
> > result = logicDAO.listSpecificArticle(string);
> > return result;
> > }
> >
> > @Override
> > public ValueEncoder< Article> create(Class< Article> type) {
> > return this;
> > }
> > }
> >
> >
> > I get following
> > HTTP Status 500 - 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
> > com.google.tapestrySection.teamAlpha.services.AppModule.contributeValueEncoderSource(MappedConfiguration,
> > LogicDAO) (at AppModule.java:1264)).
> >
> > Anyone knows how to hack this issue here? :)
> >
>
>
>
>
> --
> Thiago
Re: Resolving PersistentClass instances mapping to the same entity
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
As the exception says, both HibernateModule.contributeValueEncoderSource()
and AppModule.contributeValueEncoderSource() are contributing a
ValueEncoder for a given type and that's forbidden. Do you really need to
provide your own ValueEncoders? Doesn't the Tapestry-Hibernate provided
ones suit your needs? If you don need your own ValueEncoders, you can
contribute them using the MappedConfiguration.override() method instead of
add(). Otherwise, just don't provide your own ones.
On Mon, Jun 17, 2013 at 10:42 PM, Nomen Nomanum <ge...@outlook.com>wrote:
> Hi. :)
> I have following case:
> Article
> - -
> - -
> Fruits Vegetables
>
>
> Fruits and Vegetables inherits Article, and both Fruits and Vegetables
> have same DiscriminatorValue. Now when I try to do some ValueEncoder magic
> like in following
> public class ArticleEncoder implements ValueEncoder< Article>,
> ValueEncoderFactory< Article> {
>
> private LogicDAO logicDAO;
>
> @Override
> public String toClient(final Article v) {
> return String.valueOf(v.getName());
> }
>
> @Override
> public Artikal toValue(String string) {
> Article result = new Article();
> result = logicDAO.listSpecificArticle(string);
> return result;
> }
>
> @Override
> public ValueEncoder< Article> create(Class< Article> type) {
> return this;
> }
> }
>
>
> I get following
> HTTP Status 500 - 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
> com.google.tapestrySection.teamAlpha.services.AppModule.contributeValueEncoderSource(MappedConfiguration,
> LogicDAO) (at AppModule.java:1264)).
>
> Anyone knows how to hack this issue here? :)
>
--
Thiago