Methods Summary |
---|
public void | addDefaultListeners(org.w3c.dom.NodeList nodes, oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper helper)INTERNAL:
m_defaultListeners.put(helper, nodes);
|
public void | addDescriptor(oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor descriptor)INTERNAL:
This method will add the descriptor to the actual TopLink project as
well if it has not already been added.
// Set the persistence unit defaults (if there are any) on the descriptor.
if (m_persistenceUnit != null) {
descriptor.setAccess(m_persistenceUnit.getAccess());
descriptor.setSchema(m_persistenceUnit.getSchema());
descriptor.setCatalog(m_persistenceUnit.getCatalog());
descriptor.setIsCascadePersist(m_persistenceUnit.isCascadePersist());
descriptor.setIgnoreAnnotations(m_persistenceUnit.isMetadataComplete());
}
Project project = getSession().getProject();
ClassDescriptor descriptorOnProject = MetadataHelper.findDescriptor(project, descriptor.getJavaClass());
if (descriptorOnProject == null) {
project.addDescriptor(descriptor.getClassDescriptor());
} else {
descriptor.setDescriptor(descriptorOnProject);
}
m_allDescriptors.put(descriptor.getJavaClassName(), descriptor);
|
public void | addEmbeddable(java.lang.Class embeddable, org.w3c.dom.Node node, oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper helper)INTERNAL:
Add an embeddable that we found in an XML document.
m_embeddables.put(embeddable.getName(), helper);
m_embeddableNodes.put(embeddable.getName(), node);
|
public void | addGeneratedValue(oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing.MetadataGeneratedValue metadatageneratedvalue, java.lang.Class entityClass)INTERNAL:
m_generatedValues.put(entityClass, metadatageneratedvalue);
|
public void | addMappedSuperclass(java.lang.Class mappedSuperclass, org.w3c.dom.Node node, oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper helper)INTERNAL:
Add a mapped-superclass that we found in an XML document.
m_mappedSuperclasses.put(mappedSuperclass.getName(), helper);
m_mappedSuperclassNodes.put(mappedSuperclass.getName(), node);
|
public void | addNamedNativeQuery(oracle.toplink.essentials.internal.ejb.cmp3.metadata.queries.MetadataNamedNativeQuery namedNativeQuery)INTERNAL:
m_namedNativeQueries.put(namedNativeQuery.getName(), namedNativeQuery);
|
public void | addNamedQuery(oracle.toplink.essentials.internal.ejb.cmp3.metadata.queries.MetadataNamedQuery namedQuery)INTERNAL:
m_namedQueries.put(namedQuery.getName(), namedQuery);
|
public void | addRelationshipDescriptor(oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor descriptor)INTERNAL:
m_descriptorsWithRelationships.add(descriptor);
|
public void | addSequenceGenerator(oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing.MetadataSequenceGenerator sequenceGenerator)INTERNAL:
m_sequenceGenerators.put(sequenceGenerator.getName(), sequenceGenerator);
|
public void | addTableGenerator(oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing.MetadataTableGenerator tableGenerator)INTERNAL:
m_tableGenerators.put(tableGenerator.getName(), tableGenerator);
|
public void | cleanup()INTERNAL:
This method frees up resources acquired by this object.
// get rid of the DOM trees.
m_mappingFiles.clear();
|
public boolean | containsDescriptor(java.lang.Class cls)INTERNAL:
return m_allDescriptors.containsKey(cls.getName());
|
public boolean | enableLazyForOneToOne()INTERNAL:
return m_enableLazyForOneToOne;
|
public java.util.HashMap | getDefaultListeners()INTERNAL:
return m_defaultListeners;
|
public oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor | getDescriptor(java.lang.Class cls)INTERNAL:
if (cls == null) {
return null;
} else {
MetadataDescriptor descriptor = m_allDescriptors.get(cls.getName());
if (descriptor == null) {
throw ValidationException.classNotListedInPersistenceUnit(cls.getName());
} else {
return descriptor;
}
}
|
public java.util.Collection | getDescriptors()INTERNAL:
return m_allDescriptors.values();
|
public oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper | getEmbeddableHelper(java.lang.Class cls)INTERNAL:
return m_embeddables.get(cls.getName());
|
public org.w3c.dom.Node | getEmbeddableNode(java.lang.Class cls)INTERNAL:
return m_embeddableNodes.get(cls.getName());
|
public java.util.Collection | getEntityNames()INTERNAL:
return Collections.unmodifiableCollection(m_entityNames);
|
public oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper | getMappedSuperclassHelper(java.lang.Class cls)INTERNAL:
return m_mappedSuperclasses.get(cls.getName());
|
public org.w3c.dom.Node | getMappedSuperclassNode(java.lang.Class cls)INTERNAL:
return m_mappedSuperclassNodes.get(cls.getName());
|
public java.util.Map | getMappingFiles()INTERNAL:
return Collections.unmodifiableMap(m_mappingFiles);
|
public oracle.toplink.essentials.internal.ejb.cmp3.metadata.queries.MetadataNamedNativeQuery | getNamedNativeQuery(java.lang.String name)INTERNAL:
return m_namedNativeQueries.get(name);
|
public oracle.toplink.essentials.internal.ejb.cmp3.metadata.queries.MetadataNamedQuery | getNamedQuery(java.lang.String name)INTERNAL:
return m_namedQueries.get(name);
|
public javax.persistence.spi.PersistenceUnitInfo | getPUInfo()INTERNAL:
return m_PUInfo;
|
public oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataPersistenceUnit | getPersistenceUnit()INTERNAL:
Set the classes for processing.
return m_persistenceUnit;
|
public java.util.HashSet | getRelationshipDescriptors()INTERNAL:
return m_descriptorsWithRelationships;
|
public oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing.MetadataSequenceGenerator | getSequenceGenerator(java.lang.String name)INTERNAL:
return m_sequenceGenerators.get(name);
|
public java.util.Collection | getSequenceGenerators()INTERNAL:
return m_sequenceGenerators.values();
|
public oracle.toplink.essentials.internal.sessions.AbstractSession | getSession()INTERNAL:
return m_session;
|
public oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing.MetadataTableGenerator | getTableGenerator(java.lang.String name)INTERNAL:
return m_tableGenerators.get(name);
|
public java.util.Collection | getTableGenerators()INTERNAL:
return m_tableGenerators.values();
|
public boolean | hasConflictingSequenceGenerator(oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing.MetadataSequenceGenerator sequenceGenerator)INTERNAL:
if (hasSequenceGenerator(sequenceGenerator.getName())) {
return ! getSequenceGenerator(sequenceGenerator.getName()).equals(sequenceGenerator);
} else {
return false;
}
|
public boolean | hasConflictingTableGenerator(oracle.toplink.essentials.internal.ejb.cmp3.metadata.sequencing.MetadataTableGenerator tableGenerator)INTERNAL:
if (hasTableGenerator(tableGenerator.getName())) {
return ! getTableGenerator(tableGenerator.getName()).equals(tableGenerator);
} else {
return false;
}
|
public boolean | hasDescriptors()INTERNAL:
return ! m_allDescriptors.isEmpty();
|
public boolean | hasEmbeddable(java.lang.Class cls)INTERNAL:
return m_embeddables.containsKey(cls.getName());
|
public boolean | hasMappedSuperclass(java.lang.Class cls)INTERNAL:
return m_mappedSuperclasses.containsKey(cls.getName());
|
public boolean | hasNamedNativeQuery(java.lang.String name)INTERNAL:
return m_namedNativeQueries.containsKey(name);
|
public boolean | hasNamedQuery(java.lang.String name)INTERNAL:
return m_namedQueries.containsKey(name);
|
public boolean | hasPersistenceUnit()INTERNAL:
Set the classes for processing.
return m_persistenceUnit != null;
|
public boolean | hasSequenceGenerator(java.lang.String name)INTERNAL:
return getSequenceGenerator(name) != null;
|
public boolean | hasTableGenerator(java.lang.String name)INTERNAL:
return getTableGenerator(name) != null;
|
public void | process()INTERNAL:
Stage 2 processing. That is, it does all the extra processing that
couldn't be completed in the original metadata accessor processing.
processSequencing();
processRelationshipDescriptors();
|
public void | processNamedNativeQueries(java.lang.ClassLoader loader)INTERNAL:
Process the named native queries we found and add them to the given
session.
for (MetadataNamedNativeQuery query : m_namedNativeQueries.values()) {
HashMap<String, String> hints = processQueryHints(query.getHints(), query.getName());
Class resultClass = query.getResultClass();
if (resultClass != void.class) {
resultClass = MetadataHelper.getClassForName(resultClass.getName(), loader);
m_session.addQuery(query.getName(), EJBQueryImpl.buildSQLDatabaseQuery(resultClass, query.getEJBQLString(), hints));
} else {
String resultSetMapping = query.getResultSetMapping();
if (! resultSetMapping.equals("")) {
m_session.addQuery(query.getName(), EJBQueryImpl.buildSQLDatabaseQuery(resultSetMapping, query.getEJBQLString(), hints));
} else {
// Neither a resultClass or resultSetMapping is specified so place in a temp query on the session
m_session.addQuery(query.getName(), EJBQueryImpl.buildSQLDatabaseQuery(query.getEJBQLString(), hints));
}
}
}
|
public void | processNamedQueries(oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataValidator validator)INTERNAL:
Process the named queries we found and add them to the given session.
for (MetadataNamedQuery query : m_namedQueries.values()) {
try {
HashMap<String, String> hints = processQueryHints(query.getHints(), query.getName());
m_session.addEjbqlPlaceHolderQuery(new EJBQLPlaceHolderQuery(query.getName(), query.getEJBQLString(), hints));
} catch (Exception exception) {
validator.throwErrorProcessingNamedQueryAnnotation(query.getClass(), query.getName(), exception);
}
}
|
protected java.util.HashMap | processQueryHints(java.util.List hints, java.lang.String queryName)INTERNAL:
Process a list of MetadataQueryHint.
HashMap<String, String> hm = new HashMap<String, String>();
for (MetadataQueryHint hint : hints) {
QueryHintsHandler.verify(hint.getName(), hint.getValue(), queryName, m_session);
hm.put(hint.getName(), hint.getValue());
}
return hm;
|
protected void | processRelationshipDescriptors()INTERNAL:
Process the related descriptors.
for (MetadataDescriptor descriptor : (HashSet<MetadataDescriptor>) getRelationshipDescriptors()) {
for (RelationshipAccessor accessor : (Collection<RelationshipAccessor>) descriptor.getRelationshipAccessors()) {
accessor.processRelationship();
}
}
|
protected void | processSequencing()INTERNAL:
Process the sequencing information.
if (! m_generatedValues.isEmpty()) {
DatasourceLogin login = m_session.getProject().getLogin();
// Generators referenced from Id should have correct type
for (MetadataGeneratedValue generatedValue : m_generatedValues.values()) {
String type = generatedValue.getStrategy();
String generatorName = generatedValue.getGenerator();
if (type.equals(MetadataConstants.TABLE)) {
MetadataSequenceGenerator sequenceGenerator = m_sequenceGenerators.get(generatorName);
if (sequenceGenerator != null) {
// WIP
}
} else if (type.equals(MetadataConstants.SEQUENCE) || type.equals(MetadataConstants.IDENTITY)) {
MetadataTableGenerator tableGenerator = m_tableGenerators.get(generatorName);
if (tableGenerator != null) {
// WIP
}
}
}
Sequence defaultAutoSequence = null;
TableSequence defaultTableSequence = new TableSequence(MetadataConstants.DEFAULT_TABLE_GENERATOR);
NativeSequence defaultNativeSequence = new NativeSequence(MetadataConstants.DEFAULT_SEQUENCE_GENERATOR);
// Sequences keyed on generator names.
Hashtable<String, Sequence> sequences = new Hashtable<String, Sequence>();
for (MetadataSequenceGenerator sequenceGenerator : m_sequenceGenerators.values()) {
String sequenceGeneratorName = sequenceGenerator.getName();
String seqName = (sequenceGenerator.getSequenceName().equals("")) ? sequenceGeneratorName : sequenceGenerator.getSequenceName();
NativeSequence sequence = new NativeSequence(seqName, sequenceGenerator.getAllocationSize());
sequences.put(sequenceGeneratorName, sequence);
if (sequenceGeneratorName.equals(MetadataConstants.DEFAULT_AUTO_GENERATOR)) {
// SequenceGenerator defined with DEFAULT_AUTO_GENERATOR.
// The sequence it defines will be used as a defaultSequence.
defaultAutoSequence = sequence;
} else if (sequenceGeneratorName.equals(MetadataConstants.DEFAULT_SEQUENCE_GENERATOR)) {
// SequenceGenerator deinfed with DEFAULT_SEQUENCE_GENERATOR.
// All sequences of GeneratorType SEQUENCE and IDENTITY
// referencing non-defined generators will use a clone of
// the sequence defined by this generator.
defaultNativeSequence = sequence;
}
}
for (MetadataTableGenerator tableGenerator : m_tableGenerators.values()) {
String tableGeneratorName = tableGenerator.getName();
String seqName = (tableGenerator.getPkColumnValue().equals("")) ? tableGeneratorName : tableGenerator.getPkColumnValue();
TableSequence sequence = new TableSequence(seqName, tableGenerator.getAllocationSize(), tableGenerator.getInitialValue());
sequences.put(tableGeneratorName, sequence);
//bug 2647: pull schema and catalog defaults from the persistence Unit if they are not defined.
String catalogName = tableGenerator.getCatalog();
String schemaName = tableGenerator.getSchema();
if (this.getPersistenceUnit()!=null){
catalogName = catalogName.length()>0? catalogName: this.getPersistenceUnit().getCatalog();
schemaName = schemaName.length()>0? schemaName: this.getPersistenceUnit().getSchema();
}
// Get the database table from the @TableGenerator values.
// In case tableGenerator.table().equals("") default sequence
// table name will be extracted from sequence and used, see
// TableSequence class.
sequence.setTable(new DatabaseTable(MetadataHelper.getFullyQualifiedTableName(tableGenerator.getTable(), sequence.getTableName(), catalogName, schemaName)));
// Process the @UniqueConstraints for this table.
for (String[] uniqueConstraint : tableGenerator.getUniqueConstraints()) {
sequence.getTable().addUniqueConstraints(uniqueConstraint);
}
if (! tableGenerator.getPkColumnName().equals("")) {
sequence.setNameFieldName(tableGenerator.getPkColumnName());
}
if (! tableGenerator.getValueColumnName().equals("")) {
sequence.setCounterFieldName(tableGenerator.getValueColumnName());
}
if (tableGeneratorName.equals(MetadataConstants.DEFAULT_AUTO_GENERATOR)) {
// TableGenerator defined with DEFAULT_AUTO_GENERATOR.
// The sequence it defines will be used as a defaultSequence.
defaultAutoSequence = sequence;
} else if (tableGeneratorName.equals(MetadataConstants.DEFAULT_TABLE_GENERATOR)) {
// SequenceGenerator defined with DEFAULT_TABLE_GENERATOR.
// All sequences of GenerationType TABLE referencing non-
// defined generators will use a clone of the sequence
// defined by this generator.
defaultTableSequence = sequence;
}
}
// Finally loop through descriptors and set sequences as required into
// Descriptors and Login
for (Class entityClass : m_generatedValues.keySet()) {
MetadataDescriptor descriptor = m_allDescriptors.get(entityClass.getName());
MetadataGeneratedValue generatedValue = m_generatedValues.get(entityClass);
String generatorName = generatedValue.getGenerator();
Sequence sequence = null;
if (! generatorName.equals("")) {
sequence = sequences.get(generatorName);
}
if (sequence == null) {
if (generatedValue.getStrategy().equals(MetadataConstants.TABLE)) {
if (generatorName.equals("")) {
sequence = defaultTableSequence;
} else {
sequence = (Sequence)defaultTableSequence.clone();
sequence.setName(generatorName);
}
} else if (generatedValue.getStrategy().equals(MetadataConstants.SEQUENCE) || generatedValue.getStrategy().equals(MetadataConstants.IDENTITY)) {
if (generatorName.equals("")) {
sequence = defaultNativeSequence;
} else {
sequence = (Sequence)defaultNativeSequence.clone();
sequence.setName(generatorName);
}
}
}
if (sequence != null) {
descriptor.setSequenceNumberName(sequence.getName());
login.addSequence(sequence);
} else if (generatedValue.getStrategy().equals(MetadataConstants.AUTO)) {
if (defaultAutoSequence != null) {
descriptor.setSequenceNumberName(defaultAutoSequence.getName());
login.setDefaultSequence(defaultAutoSequence);
} else {
descriptor.setSequenceNumberName(MetadataConstants.DEFAULT_AUTO_GENERATOR);
}
}
}
}
|
public void | setEntityNames(java.util.Collection entityNames)INTERNAL:
m_entityNames.clear();
m_entityNames.addAll(entityNames);
|
public void | setMappingFiles(java.util.Map mappingFiles)INTERNAL:
m_mappingFiles.clear();
m_mappingFiles.putAll(mappingFiles);
|
public void | setPersistenceUnit(oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataPersistenceUnit persistenceUnit)INTERNAL:
Set the classes for processing.
m_persistenceUnit = persistenceUnit;
|