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 initialization.
The advice about lifecycle events at the top of the page alludes to this fact. Andrus On Sep 8, 2011, at 11:03 AM, Becker, Joel wrote: > > > https://cwiki.apache.org/CAY/setting-initial-values.html 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)? >
