use of javax.persistence.SecondaryTable in project CloudStack-archive by CloudStack-extras.
the class SqlGenerator method buildJoins.
protected static void buildJoins(StringBuilder innerJoin, Class<?> clazz) {
String tableName = DbUtil.getTableName(clazz);
SecondaryTable[] sts = DbUtil.getSecondaryTables(clazz);
ArrayList<String> secondaryTables = new ArrayList<String>();
for (SecondaryTable st : sts) {
addPrimaryKeyJoinColumns(innerJoin, tableName, st.name(), st.join(), st.pkJoinColumns());
secondaryTables.add(st.name());
}
Class<?> parent = clazz.getSuperclass();
if (parent.getAnnotation(Entity.class) != null) {
String table = DbUtil.getTableName(parent);
PrimaryKeyJoinColumn[] pkjcs = DbUtil.getPrimaryKeyJoinColumns(clazz);
assert (pkjcs != null) : "No Join columns specified for the super class";
addPrimaryKeyJoinColumns(innerJoin, tableName, table, null, pkjcs);
}
}
use of javax.persistence.SecondaryTable in project cloudstack by apache.
the class DbUtil method getSecondaryTables.
public static final SecondaryTable[] getSecondaryTables(AnnotatedElement clazz) {
SecondaryTable[] sts = null;
SecondaryTable stAnnotation = clazz.getAnnotation(SecondaryTable.class);
if (stAnnotation == null) {
SecondaryTables stsAnnotation = clazz.getAnnotation(SecondaryTables.class);
sts = stsAnnotation != null ? stsAnnotation.value() : new SecondaryTable[0];
} else {
sts = new SecondaryTable[] { stAnnotation };
}
return sts;
}
use of javax.persistence.SecondaryTable in project cloudstack by apache.
the class SqlGenerator method buildJoins.
protected static void buildJoins(StringBuilder innerJoin, Class<?> clazz) {
String tableName = DbUtil.getTableName(clazz);
SecondaryTable[] sts = DbUtil.getSecondaryTables(clazz);
ArrayList<String> secondaryTables = new ArrayList<String>();
for (SecondaryTable st : sts) {
JoinType jt = clazz.getAnnotation(JoinType.class);
String join = null;
if (jt != null) {
join = jt.type();
}
addPrimaryKeyJoinColumns(innerJoin, tableName, st.name(), join, st.pkJoinColumns());
secondaryTables.add(st.name());
}
Class<?> parent = clazz.getSuperclass();
if (parent.getAnnotation(Entity.class) != null) {
String table = DbUtil.getTableName(parent);
PrimaryKeyJoinColumn[] pkjcs = DbUtil.getPrimaryKeyJoinColumns(clazz);
assert (pkjcs != null) : "No Join columns specified for the super class";
addPrimaryKeyJoinColumns(innerJoin, tableName, table, null, pkjcs);
}
}
Aggregations