}
if ( !entity.getAssociationOverride().isEmpty() )
{
final JAnnotationUse aolst = c.implClass.annotate( cm.ref( javax.persistence.AssociationOverrides.class ) );
final JAnnotationArrayMember value = aolst.paramArray( "value" );
for ( AssociationOverride o : entity.getAssociationOverride() )
{
final JAnnotationUse ao = value.annotate( cm.ref( javax.persistence.AssociationOverride.class ) );
if ( o.getName() != null )
{
ao.param( "name", o.getName() );
}
if ( !o.getJoinColumn().isEmpty() )
{
final JAnnotationArrayMember joinColumns = ao.paramArray( "joinColumns" );
for ( JoinColumn jc : o.getJoinColumn() )
{
final JAnnotationUse jca = joinColumns.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
this.annotate( jca, jc );
}
}
}
}
if ( !entity.getAttributeOverride().isEmpty() )
{
final JAnnotationUse aolst = c.implClass.annotate( cm.ref( javax.persistence.AttributeOverrides.class ) );
final JAnnotationArrayMember value = aolst.paramArray( "value" );
for ( AttributeOverride o : entity.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 ( entity.getAttributes() != null )
{
this.annotate( cm, c, entity.getAttributes() );
}
if ( entity.getDiscriminatorColumn() != null )
{
final JAnnotationUse dc = c.implClass.annotate( cm.ref( javax.persistence.DiscriminatorColumn.class ) );
if ( entity.getDiscriminatorColumn().getColumnDefinition() != null )
{
dc.param( "columnDefinition", entity.getDiscriminatorColumn().getColumnDefinition() );
}
if ( entity.getDiscriminatorColumn().getDiscriminatorType() != null )
{
dc.param( "discriminatorType", javax.persistence.DiscriminatorType.valueOf(
entity.getDiscriminatorColumn().getDiscriminatorType().value() ) );
}
if ( entity.getDiscriminatorColumn().getLength() != null )
{
dc.param( "length", entity.getDiscriminatorColumn().getLength().intValue() );
}
if ( entity.getDiscriminatorColumn().getName() != null )
{
dc.param( "name", entity.getDiscriminatorColumn().getName() );
}
}
if ( entity.getDiscriminatorValue() != null )
{
final JAnnotationUse dv = c.implClass.annotate( cm.ref( javax.persistence.DiscriminatorValue.class ) );
dv.param( "value", entity.getDiscriminatorValue() );
}
if ( entity.getEntityListeners() != null )
{
this.annotate( c, entity.getEntityListeners() );
}
if ( entity.getExcludeDefaultListeners() != null )
{
c.implClass.annotate( cm.ref( javax.persistence.ExcludeDefaultListeners.class ) );
}
if ( entity.getExcludeSuperclassListeners() != null )
{
c.implClass.annotate( cm.ref( javax.persistence.ExcludeSuperclassListeners.class ) );
}
if ( entity.getIdClass() != null )
{
this.annotate( c, entity.getIdClass() );
}
if ( entity.getInheritance() != null )
{
final JAnnotationUse ih = c.implClass.annotate( cm.ref( javax.persistence.Inheritance.class ) );
ih.param( "strategy",
javax.persistence.InheritanceType.valueOf( entity.getInheritance().getStrategy().value() ) );
}
if ( !entity.getNamedNativeQuery().isEmpty() )
{
final JAnnotationUse nnqlst = c.implClass.annotate( cm.ref( javax.persistence.NamedNativeQueries.class ) );
final JAnnotationArrayMember value = nnqlst.paramArray( "value" );
for ( NamedNativeQuery q : entity.getNamedNativeQuery() )
{
final JAnnotationUse qa = value.annotate( cm.ref( javax.persistence.NamedNativeQuery.class ) );
qa.param( "name", q.getName() );
qa.param( "query", q.getQuery() );
if ( q.getResultClass() != null )
{
qa.param( "resultClass", cm.ref( q.getResultClass() ) );
}
if ( q.getResultSetMapping() != null )
{
qa.param( "resultSetMapping", q.getResultSetMapping() );
}
if ( !q.getHint().isEmpty() )
{
final JAnnotationArrayMember hints = qa.paramArray( "hints" );
for ( QueryHint hint : q.getHint() )
{
final JAnnotationUse qh = hints.annotate( javax.persistence.QueryHint.class );
qh.param( "name", hint.getName() );
qh.param( "value", hint.getValue() );
}
}
}
}
if ( !entity.getNamedQuery().isEmpty() )
{
final JAnnotationUse nqlst = c.implClass.annotate( cm.ref( javax.persistence.NamedQueries.class ) );
final JAnnotationArrayMember value = nqlst.paramArray( "value" );
for ( NamedQuery q : entity.getNamedQuery() )
{
final JAnnotationUse nq = value.annotate( cm.ref( javax.persistence.NamedQuery.class ) );
nq.param( "name", q.getName() );
nq.param( "query", q.getQuery() );
if ( !q.getHint().isEmpty() )
{
final JAnnotationArrayMember hints = nq.paramArray( "hints" );
for ( QueryHint hint : q.getHint() )
{
final JAnnotationUse qh = hints.annotate( javax.persistence.QueryHint.class );
qh.param( "name", hint.getName() );
qh.param( "value", hint.getValue() );
}
}
}
}
if ( entity.getPostLoad() != null )
{
final JMethod m = this.getMethod( c, entity.getPostLoad().getMethodName() );
m.annotate( cm.ref( javax.persistence.PostLoad.class ) );
}
if ( entity.getPostPersist() != null )
{
final JMethod m = this.getMethod( c, entity.getPostPersist().getMethodName() );
m.annotate( cm.ref( javax.persistence.PostPersist.class ) );
}
if ( entity.getPostRemove() != null )
{
final JMethod m = this.getMethod( c, entity.getPostRemove().getMethodName() );
m.annotate( cm.ref( javax.persistence.PostRemove.class ) );
}
if ( entity.getPostUpdate() != null )
{
final JMethod m = this.getMethod( c, entity.getPostUpdate().getMethodName() );
m.annotate( cm.ref( javax.persistence.PostUpdate.class ) );
}
if ( entity.getPrePersist() != null )
{
final JMethod m = this.getMethod( c, entity.getPreUpdate().getMethodName() );
m.annotate( cm.ref( javax.persistence.PrePersist.class ) );
}
if ( entity.getPreRemove() != null )
{
final JMethod m = this.getMethod( c, entity.getPreRemove().getMethodName() );
m.annotate( cm.ref( javax.persistence.PreRemove.class ) );
}
if ( entity.getPreUpdate() != null )
{
final JMethod m = this.getMethod( c, entity.getPreUpdate().getMethodName() );
m.annotate( cm.ref( javax.persistence.PreUpdate.class ) );
}
if ( !entity.getPrimaryKeyJoinColumn().isEmpty() )
{
final JAnnotationUse pkjcs = c.implClass.annotate( cm.ref( javax.persistence.PrimaryKeyJoinColumns.class ) );
final JAnnotationArrayMember pkjc = pkjcs.paramArray( "value" );
this.annotate( cm, pkjc, entity.getPrimaryKeyJoinColumn() );
}
if ( !entity.getSecondaryTable().isEmpty() )
{
final JAnnotationUse stlst = c.implClass.annotate( cm.ref( javax.persistence.SecondaryTables.class ) );
final JAnnotationArrayMember value = stlst.paramArray( "value" );
for ( SecondaryTable t : entity.getSecondaryTable() )
{
final JAnnotationUse st = value.annotate( cm.ref( javax.persistence.SecondaryTable.class ) );
if ( t.getCatalog() != null )
{
st.param( "catalog", t.getCatalog() );
}
if ( t.getName() != null )
{
st.param( "name", t.getName() );
}
if ( !t.getPrimaryKeyJoinColumn().isEmpty() )
{
final JAnnotationArrayMember pkjc = st.paramArray( "pkJoinColumns" );
this.annotate( cm, pkjc, entity.getPrimaryKeyJoinColumn() );
}
if ( t.getSchema() != null )
{
st.param( "schema", t.getSchema() );
}
if ( !t.getUniqueConstraint().isEmpty() )
{
final JAnnotationArrayMember uca = st.paramArray( "uniqueConstraints" );
for ( UniqueConstraint uc : t.getUniqueConstraint() )
{
final JAnnotationUse u = uca.annotate( javax.persistence.UniqueConstraint.class );
final JAnnotationArrayMember colNames = u.paramArray( "columnNames" );
for ( String cn : uc.getColumnName() )
{
colNames.param( cn );
}
}
}
}
}
if ( entity.getSequenceGenerator() != null )
{
final JAnnotationUse sg = c.implClass.annotate( cm.ref( javax.persistence.SequenceGenerator.class ) );
this.annotate( sg, entity.getSequenceGenerator() );
}
if ( !entity.getSqlResultSetMapping().isEmpty() )
{
final JAnnotationUse lst = c.implClass.annotate( cm.ref( javax.persistence.SqlResultSetMappings.class ) );
final JAnnotationArrayMember value = lst.paramArray( "value" );
for ( SqlResultSetMapping m : entity.getSqlResultSetMapping() )
{
final JAnnotationUse srsm = value.annotate( cm.ref( javax.persistence.SqlResultSetMapping.class ) );
if ( !m.getColumnResult().isEmpty() )
{
final JAnnotationArrayMember cols = srsm.paramArray( "columns" );
for ( ColumnResult cr : m.getColumnResult() )
{
final JAnnotationUse cra = cols.annotate( javax.persistence.ColumnResult.class );
cra.param( "name", cr.getName() );
}
}
if ( !m.getEntityResult().isEmpty() )
{
final JAnnotationArrayMember entities = srsm.paramArray( "entities" );
for ( EntityResult er : m.getEntityResult() )
{
final JAnnotationUse era = entities.annotate( javax.persistence.EntityResult.class );
if ( er.getDiscriminatorColumn() != null )
{
era.param( "discriminatorColumn", er.getDiscriminatorColumn() );
}
if ( er.getEntityClass() != null )
{
era.param( "entityClass", cm.ref( er.getEntityClass() ) );
}
if ( !er.getFieldResult().isEmpty() )
{
final JAnnotationArrayMember fields = era.paramArray( "fields" );
for ( FieldResult fr : er.getFieldResult() )
{
final JAnnotationUse fra = fields.annotate( javax.persistence.FieldResult.class );
if ( fr.getColumn() != null )
{
fra.param( "column", fr.getColumn() );
}
if ( fr.getName() != null )
{
fra.param( "name", fr.getName() );
}
}
}
}
}
if ( m.getName() != null )
{
srsm.param( "name", m.getName() );
}
}
}
if ( entity.getTable() != null )
{
final JAnnotationUse ta = c.implClass.annotate( cm.ref( javax.persistence.Table.class ) );
if ( entity.getTable().getCatalog() != null )
{
ta.param( "catalog", entity.getTable().getCatalog() );
}
if ( entity.getTable().getName() != null )
{
ta.param( "name", entity.getTable().getName() );
}
if ( entity.getTable().getSchema() != null )
{
ta.param( "schema", entity.getTable().getSchema() );
}
if ( !entity.getTable().getUniqueConstraint().isEmpty() )
{
final JAnnotationArrayMember uclst = ta.paramArray( "uniqueConstraints" );
for ( UniqueConstraint uc : entity.getTable().getUniqueConstraint() )
{
final JAnnotationUse uca = uclst.annotate( javax.persistence.UniqueConstraint.class );
final JAnnotationArrayMember colNames = uca.paramArray( "columnNames" );
for ( String cn : uc.getColumnName() )
{
colNames.param( cn );
}
}
}
}
if ( entity.getTableGenerator() != null )