org.eclipse.persistence.sequencing.Sequence Java Examples
The following examples show how to use
org.eclipse.persistence.sequencing.Sequence.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPAMSchemaManager.java From jeddict with Apache License 2.0 | 6 votes |
protected SequenceDefinition buildSequenceDefinition(Sequence sequence) { if (sequence.shouldAcquireValueAfterInsert()) { return null; } if (sequence instanceof TableSequence || (sequence instanceof DefaultSequence && ((DefaultSequence) sequence).getDefaultSequence() instanceof TableSequence)) { return new TableSequenceDefinition(sequence, createDatabaseSchemas); } else if (sequence instanceof UnaryTableSequence || (sequence instanceof DefaultSequence && ((DefaultSequence) sequence).getDefaultSequence() instanceof UnaryTableSequence)) { return new UnaryTableSequenceDefinition(sequence, createDatabaseSchemas); } else if (sequence instanceof NativeSequence || (sequence instanceof DefaultSequence && ((DefaultSequence) sequence).getDefaultSequence() instanceof NativeSequence)) { NativeSequence nativeSequence = null; if (sequence instanceof NativeSequence) { nativeSequence = (NativeSequence) sequence; } else { nativeSequence = (NativeSequence) ((DefaultSequence) sequence).getDefaultSequence(); } if (nativeSequence.hasDelegateSequence()) { return buildSequenceDefinition(((NativeSequence) sequence).getDelegateSequence()); } return new SequenceObjectDefinition(sequence); } else { return null; } }
Example #2
Source File: KradEclipseLinkCustomizer.java From rice with Educational Community License v2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void customize(Session session) throws Exception { String sessionName = session.getName(); // double-checked locking on ConcurrentMap List<Sequence> sequences = sequenceMap.get(sessionName); if (sequences == null) { sequences = sequenceMap.putIfAbsent(sessionName, loadSequences(session)); if (sequences == null) { sequences = sequenceMap.get(sessionName); } } loadQueryCustomizers(session); DatabaseLogin login = session.getLogin(); for (Sequence sequence : sequences) { login.addSequence(sequence); } handleDescriptorModifications(session); }
Example #3
Source File: PrefixSessionCustomizer.java From tomee with Apache License 2.0 | 6 votes |
@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()); } } }
Example #4
Source File: JPAMTableCreator.java From jeddict with Apache License 2.0 | 5 votes |
/** * This returns the Sequence Table's qualified name, without delimiting. * * @param session * @return the qualified table name */ protected String getSequenceTableName(Session session) { String sequenceTableName = null; if (session.getProject().usesSequencing()) { Sequence sequence = session.getLogin().getDefaultSequence(); if (sequence instanceof TableSequence) { sequenceTableName = ((TableSequence) sequence).getQualifiedTableName(); } } return sequenceTableName; }
Example #5
Source File: JPAMSchemaManager.java From jeddict with Apache License 2.0 | 5 votes |
/** * INTERNAL: Build the sequence definitions. */ protected HashSet<SequenceDefinition> buildSequenceDefinitions() { // Remember the processed - to handle each sequence just once. HashSet processedSequenceNames = new HashSet(); HashSet<SequenceDefinition> sequenceDefinitions = new HashSet<>(); for (ClassDescriptor descriptor : getSession().getDescriptors().values()) { if (descriptor.usesSequenceNumbers()) { String seqName = descriptor.getSequenceNumberName(); if (seqName == null) { seqName = getSession().getDatasourcePlatform().getDefaultSequence().getName(); } if (!processedSequenceNames.contains(seqName)) { processedSequenceNames.add(seqName); Sequence sequence = getSession().getDatasourcePlatform().getSequence(seqName); SequenceDefinition sequenceDefinition = buildSequenceDefinition(sequence); if (sequenceDefinition != null) { sequenceDefinitions.add(sequenceDefinition); } } } } return sequenceDefinitions; }