{
final JMethod getter = this.getGetter( c, e.getName() );
getter.annotate( cm.ref( javax.persistence.Embedded.class ) );
if ( !e.getAttributeOverride().isEmpty() )
{
final JAnnotationUse aolst = getter.annotate( cm.ref( javax.persistence.AttributeOverrides.class ) );
final JAnnotationArrayMember value = aolst.paramArray( "value" );
for ( AttributeOverride o : e.getAttributeOverride() )
{
final JAnnotationUse ao = value.annotate( cm.ref( javax.persistence.AttributeOverride.class ) );
if ( o.getColumn() != null )
{
final JAnnotationUse ac = ao.param( "column", cm.ref( javax.persistence.Column.class ) );
this.annotate( ac, o.getColumn() );
}
if ( o.getName() != null )
{
ao.param( "name", o.getName() );
}
}
}
}
if ( a.getEmbeddedId() != null )
{
final JMethod getter = this.getGetter( c, a.getEmbeddedId().getName() );
getter.annotate( cm.ref( javax.persistence.EmbeddedId.class ) );
if ( !a.getEmbeddedId().getAttributeOverride().isEmpty() )
{
final JAnnotationUse aolst = getter.annotate( cm.ref( javax.persistence.AttributeOverrides.class ) );
final JAnnotationArrayMember value = aolst.paramArray( "value" );
for ( AttributeOverride o : a.getEmbeddedId().getAttributeOverride() )
{
final JAnnotationUse ao = value.annotate( cm.ref( javax.persistence.AttributeOverride.class ) );
if ( o.getColumn() != null )
{
final JAnnotationUse ac = ao.param( "column", cm.ref( javax.persistence.Column.class ) );
this.annotate( ac, o.getColumn() );
}
if ( o.getName() != null )
{
ao.param( "name", o.getName() );
}
}
}
}
for ( Id i : a.getId() )
{
final JMethod getter = this.getGetter( c, i.getName() );
getter.annotate( cm.ref( javax.persistence.Id.class ) );
if ( i.getColumn() != null )
{
final JAnnotationUse column = getter.annotate( cm.ref( javax.persistence.Column.class ) );
this.annotate( column, i.getColumn() );
}
if ( i.getGeneratedValue() != null )
{
final JAnnotationUse gv = getter.annotate( cm.ref( javax.persistence.GeneratedValue.class ) );
if ( i.getGeneratedValue().getGenerator() != null )
{
gv.param( "generator", i.getGeneratedValue().getGenerator() );
}
if ( i.getGeneratedValue().getStrategy() != null )
{
gv.param( "strategy", javax.persistence.GenerationType.valueOf(
i.getGeneratedValue().getStrategy().value() ) );
}
}
if ( i.getSequenceGenerator() != null )
{
final JAnnotationUse gen = getter.annotate( cm.ref( javax.persistence.SequenceGenerator.class ) );
this.annotate( gen, i.getSequenceGenerator() );
}
if ( i.getTableGenerator() != null )
{
final JAnnotationUse gen = getter.annotate( cm.ref( javax.persistence.TableGenerator.class ) );
this.annotate( gen, i.getTableGenerator() );
}
if ( i.getTemporal() != null )
{
final JAnnotationUse temp = getter.annotate( cm.ref( javax.persistence.Temporal.class ) );
temp.param( "value", javax.persistence.TemporalType.valueOf( i.getTemporal().value() ) );
}
}
for ( ManyToMany m : a.getManyToMany() )
{
final JMethod getter = this.getGetter( c, m.getName() );
final JAnnotationUse m2m = getter.annotate( cm.ref( javax.persistence.ManyToMany.class ) );
if ( m.getCascade() != null )
{
this.annotate( m2m, m.getCascade() );
}
if ( m.getFetch() != null )
{
m2m.param( "fetch", javax.persistence.FetchType.valueOf( m.getFetch().value() ) );
}
if ( m.getJoinTable() != null )
{
final JAnnotationUse jt = getter.annotate( cm.ref( javax.persistence.JoinTable.class ) );
this.annotate( cm, jt, m.getJoinTable() );
}
if ( m.getMapKey() != null )
{
final JAnnotationUse mk = getter.annotate( cm.ref( javax.persistence.MapKey.class ) );
mk.param( "name", m.getMapKey().getName() );
}
if ( m.getMappedBy() != null )
{
m2m.param( "mappedBy", m.getMappedBy() );
}
if ( m.getOrderBy() != null )
{
final JAnnotationUse ob = getter.annotate( cm.ref( javax.persistence.OrderBy.class ) );
ob.param( "value", m.getOrderBy() );
}
if ( m.getTargetEntity() != null )
{
m2m.param( "targetEntity", cm.ref( m.getTargetEntity() ) );
}
}
for ( ManyToOne m : a.getManyToOne() )
{
final JMethod getter = this.getGetter( c, m.getName() );
final JAnnotationUse m2o = getter.annotate( cm.ref( javax.persistence.ManyToOne.class ) );
if ( m.getCascade() != null )
{
this.annotate( m2o, m.getCascade() );
}
if ( m.getFetch() != null )
{
m2o.param( "fetch", javax.persistence.FetchType.valueOf( m.getFetch().value() ) );
}
if ( !m.getJoinColumn().isEmpty() )
{
for ( JoinColumn jc : m.getJoinColumn() )
{
final JAnnotationUse jca = getter.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
this.annotate( jca, jc );
}
}
if ( m.getJoinTable() != null )
{
final JAnnotationUse jt = getter.annotate( cm.ref( javax.persistence.JoinTable.class ) );
this.annotate( cm, jt, m.getJoinTable() );
}
if ( m.getTargetEntity() != null )
{
m2o.param( "targetEntity", cm.ref( m.getTargetEntity() ) );
}
if ( m.isOptional() != null )
{
m2o.param( "optional", m.isOptional().booleanValue() );
}
}
for ( OneToMany m : a.getOneToMany() )
{
final JMethod getter = this.getGetter( c, m.getName() );
final JAnnotationUse o2m = getter.annotate( cm.ref( javax.persistence.OneToMany.class ) );
if ( m.getCascade() != null )
{
this.annotate( o2m, m.getCascade() );
}
if ( m.getFetch() != null )
{
o2m.param( "fetch", javax.persistence.FetchType.valueOf( m.getFetch().value() ) );
}
if ( !m.getJoinColumn().isEmpty() )
{
for ( JoinColumn jc : m.getJoinColumn() )
{
final JAnnotationUse jca = getter.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
this.annotate( jca, jc );
}
}
if ( m.getJoinTable() != null )
{
final JAnnotationUse jt = getter.annotate( cm.ref( javax.persistence.JoinTable.class ) );
this.annotate( cm, jt, m.getJoinTable() );
}
if ( m.getMapKey() != null )
{
final JAnnotationUse mk = getter.annotate( cm.ref( javax.persistence.MapKey.class ) );
mk.param( "name", m.getMapKey().getName() );
}
if ( m.getMappedBy() != null )
{
o2m.param( "mappedBy", m.getMappedBy() );
}
if ( m.getOrderBy() != null )
{
final JAnnotationUse ob = getter.annotate( cm.ref( javax.persistence.OrderBy.class ) );
ob.param( "value", m.getOrderBy() );
}
if ( m.getTargetEntity() != null )
{
o2m.param( "targetEntity", cm.ref( m.getTargetEntity() ) );
}
}
for ( OneToOne m : a.getOneToOne() )
{
final JMethod getter = this.getGetter( c, m.getName() );
final JAnnotationUse o2o = getter.annotate( cm.ref( javax.persistence.OneToOne.class ) );
if ( m.getCascade() != null )
{
this.annotate( o2o, m.getCascade() );
}
if ( m.isOptional() != null )
{
o2o.param( "optional", m.isOptional().booleanValue() );
}
if ( m.getFetch() != null )
{
o2o.param( "fetch", javax.persistence.FetchType.valueOf( m.getFetch().value() ) );
}
if ( !m.getJoinColumn().isEmpty() )
{
for ( JoinColumn jc : m.getJoinColumn() )
{
final JAnnotationUse jca = getter.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
this.annotate( jca, jc );
}
}
if ( m.getJoinTable() != null )
{
final JAnnotationUse jt = getter.annotate( cm.ref( javax.persistence.JoinTable.class ) );
this.annotate( cm, jt, m.getJoinTable() );
}
if ( m.getMappedBy() != null )
{
o2o.param( "mappedBy", m.getMappedBy() );
}
if ( !m.getPrimaryKeyJoinColumn().isEmpty() )
{
final JAnnotationUse pkjcs = getter.annotate( cm.ref( javax.persistence.PrimaryKeyJoinColumns.class ) );
final JAnnotationArrayMember pkjc = pkjcs.paramArray( "value" );
this.annotate( cm, pkjc, m.getPrimaryKeyJoinColumn() );
}
if ( m.getTargetEntity() != null )
{
o2o.param( "targetEntity", cm.ref( m.getTargetEntity() ) );
}
}
for ( Transient t : a.getTransient() )
{
this.annotate( c, t );
}
for ( Version v : a.getVersion() )
{
final JMethod getter = this.getGetter( c, v.getName() );
getter.annotate( cm.ref( javax.persistence.Version.class ) );
if ( v.getColumn() != null )
{
final JAnnotationUse col = getter.annotate( cm.ref( javax.persistence.Column.class ) );
this.annotate( col, v.getColumn() );
}
if ( v.getTemporal() != null )
{
final JAnnotationUse temp = getter.annotate( cm.ref( javax.persistence.Temporal.class ) );
temp.param( "value", javax.persistence.TemporalType.valueOf( v.getTemporal().value() ) );
}
}
}