@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()); } } }
protected String setDefaultOrAddSequenceString(Sequence sequence, boolean isSetDefault) { String prefix; if (isSetDefault) { prefix = "login.setDefaultSequence(new "; } else { prefix = "login.addSequence(new "; } String str; if (sequence instanceof TableSequence) { TableSequence ts = (TableSequence)sequence; str = "TableSequence(\"" + ts.getName() + "\", " + ts.getPreallocationSize() + ", \"" + ts.getTableName() + "\", \"" + ts.getNameFieldName() + "\", \"" + ts.getCounterFieldName() + "\"));"; } else if (sequence instanceof UnaryTableSequence) { UnaryTableSequence uts = (UnaryTableSequence)sequence; str = "UnaryTableSequence(\"" + uts.getName() + "\", " + uts.getPreallocationSize() + ", \"" + uts.getCounterFieldName() + "\"));"; } else { String typeName = Helper.getShortClassName(sequence); str = typeName + "(\"" + sequence.getName() + "\", " + sequence.getPreallocationSize() + "));"; } return prefix + str; }
protected String setDefaultOrAddSequenceString(Sequence sequence, boolean isSetDefault) { String prefix; if (isSetDefault) { prefix = "login.setDefaultSequence(new "; } else { prefix = "login.addSequence(new "; } String str; if (sequence instanceof TableSequence) { TableSequence ts = (TableSequence)sequence; str = "TableSequence(\"" + ts.getName() + "\", " + ts.getPreallocationSize() + ", \"" + ts.getTableName() + "\", \"" + ts.getNameFieldName() + "\", \"" + ts.getCounterFieldName() + "\"));"; } else if (sequence instanceof UnaryTableSequence) { UnaryTableSequence uts = (UnaryTableSequence)sequence; str = "UnaryTableSequence(\"" + uts.getName() + "\", " + uts.getPreallocationSize() + ", \"" + uts.getCounterFieldName() + "\"));"; } else { String typeName = Helper.getShortClassName(sequence); str = typeName + "(\"" + sequence.getName() + "\", " + sequence.getPreallocationSize() + "));"; } return prefix + str; }
protected String setDefaultOrAddSequenceString(Sequence sequence, boolean isSetDefault) { String prefix; if (isSetDefault) { prefix = "login.setDefaultSequence(new "; } else { prefix = "login.addSequence(new "; } String str; if (sequence instanceof TableSequence) { TableSequence ts = (TableSequence)sequence; str = "TableSequence(\"" + ts.getName() + "\", " + ts.getPreallocationSize() + ", \"" + ts.getTableName() + "\", \"" + ts.getNameFieldName() + "\", \"" + ts.getCounterFieldName() + "\"));"; } else if (sequence instanceof UnaryTableSequence) { UnaryTableSequence uts = (UnaryTableSequence)sequence; str = "UnaryTableSequence(\"" + uts.getName() + "\", " + uts.getPreallocationSize() + ", \"" + uts.getCounterFieldName() + "\"));"; } else { String typeName = Helper.getShortClassName(sequence); str = typeName + "(\"" + sequence.getName() + "\", " + sequence.getPreallocationSize() + "));"; } return prefix + str; }