Wiki source code of Server-Side Entity.java Template
Last modified by David Avendasora on 2009/04/07 07:22
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{code}} | ||
2 | #if ($entity.packageName) | ||
3 | package $entity.packageName; | ||
4 | |||
5 | #end | ||
6 | import org.apache.log4j.Logger; | ||
7 | |||
8 | import com.webobjects.eoaccess.EOUtilities; | ||
9 | import com.webobjects.eocontrol.EOEditingContext; | ||
10 | |||
11 | public class ${entity.classNameWithoutPackage} extends ${entity.prefixClassNameWithOptionalPackage} { | ||
12 | |||
13 | @SuppressWarnings("unused") | ||
14 | private static Logger log = Logger.getLogger(${entity.classNameWithoutPackage}.class); | ||
15 | private static final long serialVersionUID = 1L; | ||
16 | |||
17 | public ${entity.classNameWithoutPackage}() { | ||
18 | super(); | ||
19 | // Don't do anything here! All initial object setup must | ||
20 | // be done in the awakeFromInsertion(EOEditingContext) method. | ||
21 | } | ||
22 | |||
23 | public ${entity.classNameWithoutPackage} localInstance(EOEditingContext ec) { | ||
24 | return (${entity.classNameWithoutPackage}) EOUtilities.localInstanceOfObject(ec, this); | ||
25 | } | ||
26 | |||
27 | @Override | ||
28 | public void awakeFromInsertion(EOEditingContext ec) { | ||
29 | super.awakeFromInsertion(ec); | ||
30 | /* | ||
31 | * All attributes you set here should be wrapped in a if(attribute == null) conditional, otherwise | ||
32 | * many bad things can happen as new instances are copied back from the java client and inserted into | ||
33 | * the server-side editing context! | ||
34 | */ | ||
35 | } | ||
36 | } | ||
37 | |||
38 | {{/code}} |