You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Brett Knights <br...@knightsofthenet.com> on 2007/01/08 23:14:17 UTC
Read Only Properties
Does anyone have a pattern for creating read only fields?
While I am obviously not persisting the RO properties having to have the
setters as public methods is bad design. Is there any downside(from an
iBatis POV) to exposing an interface as the business class and using a
concrete class for managing persistence (see below) ? Does it seem
pointless to worry about?
interface modelObj{
A getA()
}
class iBatisObj implements modelObj{
public setA(A a);
public A getA();
}
Re: Read Only Properties
Posted by Paul Benedict <pb...@apache.org>.
Brett,
80% of my model objects have immutable interfaces. It works so good for
thread-safety. If I ever need to alter an object, my model objects have
a copy constructor that accept an instance of the interface.
Paul
Brett Knights wrote:
> Does anyone have a pattern for creating read only fields?
>
> While I am obviously not persisting the RO properties having to have the
> setters as public methods is bad design. Is there any downside(from an
> iBatis POV) to exposing an interface as the business class and using a
> concrete class for managing persistence (see below) ? Does it seem
> pointless to worry about?
>
> interface modelObj{
> A getA()
> }
>
> class iBatisObj implements modelObj{
> public setA(A a);
> public A getA();
> }
>
Re: Read Only Properties
Posted by Paul Benedict <pb...@apache.org>.
Jeff,
Can we get this documented in the user guide? :)
Paul
Jeff Butler wrote:
> iBATIS can use private getters/setters as of iBATIS 2.2. I think this
> is better than the interface.
>
> Jeff Butler
>
>
>
> On 1/8/07, *Brett Knights* <brett@knightsofthenet.com
> <ma...@knightsofthenet.com>> wrote:
>
> Does anyone have a pattern for creating read only fields?
>
> While I am obviously not persisting the RO properties having to have
> the
> setters as public methods is bad design. Is there any downside(from an
> iBatis POV) to exposing an interface as the business class and using a
> concrete class for managing persistence (see below) ? Does it seem
> pointless to worry about?
>
> interface modelObj{
> A getA()
> }
>
> class iBatisObj implements modelObj{
> public setA(A a);
> public A getA();
> }
>
>
Re: Read Only Properties
Posted by Jeff Butler <je...@gmail.com>.
iBATIS can use private getters/setters as of iBATIS 2.2. I think this is
better than the interface.
Jeff Butler
On 1/8/07, Brett Knights <br...@knightsofthenet.com> wrote:
>
> Does anyone have a pattern for creating read only fields?
>
> While I am obviously not persisting the RO properties having to have the
> setters as public methods is bad design. Is there any downside(from an
> iBatis POV) to exposing an interface as the business class and using a
> concrete class for managing persistence (see below) ? Does it seem
> pointless to worry about?
>
> interface modelObj{
> A getA()
> }
>
> class iBatisObj implements modelObj{
> public setA(A a);
> public A getA();
> }
>