use of org.eclipse.persistence.sequencing.TableSequence in project tomee by apache.
the class PrefixSessionCustomizer method customize.
@Override
public void customize(final Session session) throws Exception {
if (JPAThreadContext.infos.containsKey("properties")) {
final String prefix = ((Properties) JPAThreadContext.infos.get("properties")).getProperty("openejb.jpa.table_prefix");
final List<DatabaseTable> tables = new ArrayList<DatabaseTable>();
for (final ClassDescriptor cd : session.getDescriptors().values()) {
for (final DatabaseTable table : cd.getTables()) {
update(prefix, tables, table);
}
for (final DatabaseMapping mapping : cd.getMappings()) {
if (mapping instanceof ManyToManyMapping) {
update(prefix, tables, ((ManyToManyMapping) mapping).getRelationTable());
} else if (mapping instanceof DirectCollectionMapping) {
update(prefix, tables, ((DirectCollectionMapping) mapping).getReferenceTable());
}
// TODO: else check we need to update something
}
}
final Sequence sequence = session.getDatasourcePlatform().getDefaultSequence();
if (sequence instanceof TableSequence) {
final TableSequence ts = ((TableSequence) sequence);
ts.setName(prefix + ts.getName());
}
}
}
Aggregations