cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Can default values be set in Constructor instead of setPersistenceState()?
Date Thu, 08 Sep 2011 15:10:04 GMT
Yes, you can set values in constructor, but keep in mind that persistent object has a certain
lifecycle. So constructor can be called for the NEW objects that you create, as well as for
COMMITTED objects fetched by Cayenne from DB. Those 2 cases are very likely to require different

The advice about lifecycle events at the top of the page alludes to this fact.


On Sep 8, 2011, at 11:03 AM, Becker, Joel wrote:

> says "the best
> place to set default/initial values in the newly created object is in
> the setPersistenceState". Is there a problem with setting the default
> values in a default constructor (following java general best practices)?

View raw message