You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andreas Pursian <dg...@gmx.net> on 2010/07/28 11:24:22 UTC

T5: Beaneditor annotations are ignored when fetched as lazy association

Dear List members,

sorry for reposting my question but I still couldn't find a solution for
this problem.

I experienced a strange problem while combining Beaneditor annotations
with objects fetched through a lazy OneToOne association.
Beaneditor annotations on setter methods like
(@DataType(value="longtext") or @NonVisual) gets ignored when the
OneToOne association is lazy fetched (fetch=FetchType.LAZY). Annotations
on getter methods (like @Validate("required")) are working probably.
Eager fetching the association solves this issue but is unfortunately no
option due to a complex data scheme.

The data scheme looks like this:

MainClassA  --> DataClassB
	    --> DataClassC
	    --> DataClassD
	    etc.

MainClassA has a number of OneToOne associations. Each of these
associated data classes are simple POJOs which will get edited/displayed
by beaneditor-/display components.

Here is an example of our OneToOne association:

@OneToOne(cascade={CascadeType.PERSIST,
  		  CascadeType.MERGE, 	
		  CascadeType.REMOVE},
	  optional=false)
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
@JoinColumn(name="classB_fk", unique=true )
public DataClassB getDataClassBData() {

	//do something	
}

If I switched to lazy fetching like this

@OneToOne(cascade={CascadeType.PERSIST,
  		  CascadeType.MERGE, 	
		  CascadeType.REMOVE},
	  optional=false,
	  fetch=FetchType.LAZY)

the problem occur.

I do use T5.1.0.5 and Hibernate 3.3.1GA

Thanks in advance ....

Cheers
Andreas

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


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


Re: T5: Beaneditor annotations are ignored when fetched as lazy association

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 28 Jul 2010 10:00:24 -0300, Pablo dos Reis  
<pa...@gmail.com> wrote:

> Hi Andreas,

Hi, guys!

> I recommend to save the entities separate.
> save(A); save(B); save(C); save(Main);
> Maybe it has been a bug in hibernate.
> http://jira.springframework.org/browse/SPR-7319

Andreas, are you putting the annotations in the fields or in the getter  
methods?

I guess Pablo is right: it seems that the proxy used by Hibernate doesn't  
have the same annotations in fields, while it keeps the annotations in  
methods.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: T5: Beaneditor annotations are ignored when fetched as lazy association

Posted by Pablo dos Reis <pa...@gmail.com>.
Hi Andreas,

I recommend to save the entities separate.

save(A); save(B); save(C); save(Main);

Maybe it has been a bug in hibernate.

http://jira.springframework.org/browse/SPR-7319



2010/7/28 Andreas Pursian <dg...@gmx.net>

> Dear List members,
>
> sorry for reposting my question but I still couldn't find a solution for
> this problem.
>
> I experienced a strange problem while combining Beaneditor annotations
> with objects fetched through a lazy OneToOne association.
> Beaneditor annotations on setter methods like
> (@DataType(value="longtext") or @NonVisual) gets ignored when the
> OneToOne association is lazy fetched (fetch=FetchType.LAZY). Annotations
> on getter methods (like @Validate("required")) are working probably.
> Eager fetching the association solves this issue but is unfortunately no
> option due to a complex data scheme.
>
> The data scheme looks like this:
>
> MainClassA  --> DataClassB
>            --> DataClassC
>            --> DataClassD
>            etc.
>
> MainClassA has a number of OneToOne associations. Each of these
> associated data classes are simple POJOs which will get edited/displayed
> by beaneditor-/display components.
>
> Here is an example of our OneToOne association:
>
> @OneToOne(cascade={CascadeType.PERSIST,
>                  CascadeType.MERGE,
>                  CascadeType.REMOVE},
>          optional=false)
> @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
> @JoinColumn(name="classB_fk", unique=true )
> public DataClassB getDataClassBData() {
>
>        //do something
> }
>
> If I switched to lazy fetching like this
>
> @OneToOne(cascade={CascadeType.PERSIST,
>                  CascadeType.MERGE,
>                  CascadeType.REMOVE},
>          optional=false,
>          fetch=FetchType.LAZY)
>
> the problem occur.
>
> I do use T5.1.0.5 and Hibernate 3.3.1GA
>
> Thanks in advance ....
>
> Cheers
> Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Pablo Henrique dos Reis