Java Reference
In-Depth Information
private String areaCode;
/**
*@generated
*/
@Id
@Column(name="PHONE_ID")
@GeneratedValue(strategy=GenerationType.AUTO)
private int phoneId;
/**
*@generated
*/
@ManyToOne
@JoinColumn(name="PERSON_ID")
private org.eclipse.example.Person owner;
// Remaining getters and setters here...
}
7.3.2 Using the DNC Model with Templates
To compare the approaches to generating Java, we now develop a template that
generates the same code as the approach in the previous section but passes an
instance of our DNC model instead of using an instance of JEM produced by a
QVT. This template handles only Entity beans, although that could easily be
extended to generate Session beans as well.
« IMPORT dnc»
« EXTENSION templates::java::dncUtil»
« DEFINE Main FOR oocore::Package»
« EXPAND package FOREACH contents.typeSelect(oocore::Package)»
« ENDDEFINE »
« DEFINE package FOR oocore::Package-»
« EXPAND entity FOREACH contents.typeSelect(dnc::Archetype).select(a |
a.isEntity())»
« EXPAND package FOREACH contents.typeSelect(oocore::Package)»
« ENDDEFINE »
« DEFINE entity FOR dnc::Archetype-»
« FILE this .fullyQualifiedPath() -»
« IF package.isValid()-»
package «package.fullyQualifiedName()»;
« ENDIF »
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.Id;
Search WWH ::




Custom Search