本文整理汇总了Java中org.hibernate.mapping.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于org.hibernate.mapping包,在下文中一共展示了Property类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addProperty
import org.hibernate.mapping.Property; //导入依赖的package包/类
public void addProperty(Property prop, XClass declaringClass) {
if ( prop.getValue() instanceof Component ) {
//TODO handle quote and non quote table comparison
String tableName = prop.getValue().getTable().getName();
if ( getJoinsPerRealTableName().containsKey( tableName ) ) {
final Join join = getJoinsPerRealTableName().get( tableName );
addPropertyToJoin( prop, declaringClass, join );
}
else {
addPropertyToPersistentClass( prop, declaringClass );
}
}
else {
addPropertyToPersistentClass( prop, declaringClass );
}
}
示例2: addPropertyToPersistentClass
import org.hibernate.mapping.Property; //导入依赖的package包/类
private void addPropertyToPersistentClass(Property prop, XClass declaringClass) {
if ( declaringClass != null ) {
final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass );
if ( inheritanceState == null ) {
throw new AssertionFailure(
"Declaring class is not found in the inheritance state hierarchy: " + declaringClass
);
}
if ( inheritanceState.isEmbeddableSuperclass() ) {
persistentClass.addMappedsuperclassProperty(prop);
addPropertyToMappedSuperclass( prop, declaringClass );
}
else {
persistentClass.addProperty( prop );
}
}
else {
persistentClass.addProperty( prop );
}
}
示例3: addPropertyToJoin
import org.hibernate.mapping.Property; //导入依赖的package包/类
private void addPropertyToJoin(Property prop, XClass declaringClass, Join join) {
if ( declaringClass != null ) {
final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass );
if ( inheritanceState == null ) {
throw new AssertionFailure(
"Declaring class is not found in the inheritance state hierarchy: " + declaringClass
);
}
if ( inheritanceState.isEmbeddableSuperclass() ) {
join.addMappedsuperclassProperty(prop);
addPropertyToMappedSuperclass( prop, declaringClass );
}
else {
join.addProperty( prop );
}
}
else {
join.addProperty( prop );
}
}
示例4: shallowCopy
import org.hibernate.mapping.Property; //导入依赖的package包/类
/**
* create a property copy reusing the same value
*/
public static Property shallowCopy(Property property) {
Property clone = new Property();
clone.setCascade( property.getCascade() );
clone.setInsertable( property.isInsertable() );
clone.setLazy( property.isLazy() );
clone.setName( property.getName() );
clone.setNodeName( property.getNodeName() );
clone.setNaturalIdentifier( property.isNaturalIdentifier() );
clone.setOptimisticLocked( property.isOptimisticLocked() );
clone.setOptional( property.isOptional() );
clone.setPersistentClass( property.getPersistentClass() );
clone.setPropertyAccessorName( property.getPropertyAccessorName() );
clone.setSelectable( property.isSelectable() );
clone.setUpdateable( property.isUpdateable() );
clone.setValue( property.getValue() );
return clone;
}
示例5: matchColumnsByProperty
import org.hibernate.mapping.Property; //导入依赖的package包/类
private static void matchColumnsByProperty(Property property, Map<Column, Set<Property>> columnsToProperty) {
if ( property == null ) return;
if ( "noop".equals( property.getPropertyAccessorName() )
|| "embedded".equals( property.getPropertyAccessorName() ) ) {
return;
}
// FIXME cannot use subproperties becasue the caller needs top level properties
// if ( property.isComposite() ) {
// Iterator subProperties = ( (Component) property.getValue() ).getPropertyIterator();
// while ( subProperties.hasNext() ) {
// matchColumnsByProperty( (Property) subProperties.next(), columnsToProperty );
// }
// }
else {
Iterator columnIt = property.getColumnIterator();
while ( columnIt.hasNext() ) {
Object column = columnIt.next(); //can be a Formula so we don't cast
//noinspection SuspiciousMethodCalls
if ( columnsToProperty.containsKey( column ) ) {
columnsToProperty.get( column ).add( property );
}
}
}
}
示例6: addProperty
import org.hibernate.mapping.Property; //导入依赖的package包/类
public void addProperty(Property prop, Ejb3Column[] columns, XClass declaringClass) {
//Ejb3Column.checkPropertyConsistency( ); //already called earlier
/*
* Check table matches between the component and the columns
* if not, change the component table if no properties are set
* if a property is set already the core cannot support that
*/
if (columns != null) {
Table table = columns[0].getTable();
if ( !table.equals( component.getTable() ) ) {
if ( component.getPropertySpan() == 0 ) {
component.setTable( table );
}
else {
throw new AnnotationException(
"A component cannot hold properties split into 2 different tables: "
+ this.getPath()
);
}
}
}
addProperty( prop, declaringClass );
}
示例7: makePropertyAndValue
import org.hibernate.mapping.Property; //导入依赖的package包/类
private Property makePropertyAndValue() {
validateBind();
LOG.debugf( "MetadataSourceProcessor property %s with lazy=%s", name, lazy );
final String containerClassName = holder.getClassName();
holder.startingProperty( property );
simpleValueBinder = new SimpleValueBinder();
simpleValueBinder.setMappings( mappings );
simpleValueBinder.setPropertyName( name );
simpleValueBinder.setReturnedClassName( returnedClassName );
simpleValueBinder.setColumns( columns );
simpleValueBinder.setPersistentClassName( containerClassName );
simpleValueBinder.setType(
property,
returnedClass,
containerClassName,
holder.resolveAttributeConverterDefinition( property )
);
simpleValueBinder.setMappings( mappings );
simpleValueBinder.setReferencedEntityName( referencedEntityName );
simpleValueBinder.setAccessType( accessType );
SimpleValue propertyValue = simpleValueBinder.make();
setValue( propertyValue );
return makeProperty();
}
示例8: AbstractComponentTuplizer
import org.hibernate.mapping.Property; //导入依赖的package包/类
protected AbstractComponentTuplizer(Component component) {
propertySpan = component.getPropertySpan();
getters = new Getter[propertySpan];
setters = new Setter[propertySpan];
Iterator iter = component.getPropertyIterator();
boolean foundCustomAccessor=false;
int i = 0;
while ( iter.hasNext() ) {
Property prop = ( Property ) iter.next();
getters[i] = buildGetter( component, prop );
setters[i] = buildSetter( component, prop );
if ( !prop.isBasicPropertyAccessor() ) {
foundCustomAccessor = true;
}
i++;
}
hasCustomAccessors = foundCustomAccessor;
instantiator = buildInstantiator( component );
}
示例9: ComponentMetamodel
import org.hibernate.mapping.Property; //导入依赖的package包/类
public ComponentMetamodel(Component component) {
// this.sessionFactory = sessionFactory;
this.role = component.getRoleName();
this.isKey = component.isKey();
propertySpan = component.getPropertySpan();
properties = new StandardProperty[propertySpan];
Iterator itr = component.getPropertyIterator();
int i = 0;
while ( itr.hasNext() ) {
Property property = ( Property ) itr.next();
properties[i] = PropertyFactory.buildStandardProperty( property, false );
propertyIndexes.put( property.getName(), i );
i++;
}
entityMode = component.hasPojoRepresentation() ? EntityMode.POJO : EntityMode.MAP;
// todo : move this to SF per HHH-3517; also see HHH-1907 and ComponentMetamodel
final ComponentTuplizerFactory componentTuplizerFactory = new ComponentTuplizerFactory();
final String tuplizerClassName = component.getTuplizerImplClassName( entityMode );
this.componentTuplizer = tuplizerClassName == null ? componentTuplizerFactory.constructDefaultTuplizer(
entityMode,
component
) : componentTuplizerFactory.constructTuplizer( tuplizerClassName, component );
}
示例10: fixSchemaInFormulas
import org.hibernate.mapping.Property; //导入依赖的package包/类
public static void fixSchemaInFormulas(Configuration cfg) {
cfg.buildMappings();
String schema = cfg.getProperty("default_schema");
if (schema!=null) {
for (Iterator i=cfg.getClassMappings();i.hasNext();) {
PersistentClass pc = (PersistentClass)i.next();
for (Iterator j=pc.getPropertyIterator();j.hasNext();) {
Property p = (Property)j.next();
for (Iterator k=p.getColumnIterator();k.hasNext();) {
Selectable c = (Selectable)k.next();
if (c instanceof Formula) {
Formula f = (Formula)c;
if (f.getFormula()!=null && f.getFormula().indexOf("%SCHEMA%")>=0) {
f.setFormula(f.getFormula().replaceAll("%SCHEMA%", schema));
sLog.debug("Schema updated in "+pc.getClassName()+"."+p.getName()+" to "+f.getFormula());
}
}
}
}
}
}
}
示例11: getPropertyAccessor
import org.hibernate.mapping.Property; //导入依赖的package包/类
/**
* Retrieves a PropertyAccessor instance based on the given property definition and
* entity mode.
*
* @param property The property for which to retrieve an accessor.
* @param mode The mode for the resulting entity.
* @return An appropriate accessor.
* @throws MappingException
*/
public static PropertyAccessor getPropertyAccessor(Property property, EntityMode mode) throws MappingException {
//TODO: this is temporary in that the end result will probably not take a Property reference per-se.
if ( null == mode || EntityMode.POJO.equals( mode ) ) {
return getPojoPropertyAccessor( property.getPropertyAccessorName() );
}
else if ( EntityMode.MAP.equals( mode ) ) {
return getDynamicMapPropertyAccessor();
}
else if ( EntityMode.DOM4J.equals( mode ) ) {
//TODO: passing null here, because this method is not really used for DOM4J at the moment
// but it is still a bug, if we don't get rid of this!
return getDom4jPropertyAccessor( property.getAccessorPropertyName( mode ), property.getType(), null );
}
else {
throw new MappingException( "Unknown entity mode [" + mode + "]" );
}
}
示例12: ComponentMetamodel
import org.hibernate.mapping.Property; //导入依赖的package包/类
public ComponentMetamodel(Component component) {
// this.sessionFactory = sessionFactory;
this.role = component.getRoleName();
this.isKey = component.isKey();
propertySpan = component.getPropertySpan();
properties = new StandardProperty[propertySpan];
Iterator itr = component.getPropertyIterator();
int i = 0;
while ( itr.hasNext() ) {
Property property = ( Property ) itr.next();
properties[i] = PropertyFactory.buildStandardProperty( property, false );
propertyIndexes.put( property.getName(), new Integer( i ) );
i++;
}
tuplizerMapping = new ComponentEntityModeToTuplizerMapping( component );
}
示例13: getColumnNames
import org.hibernate.mapping.Property; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected String[] getColumnNames( Class peristentClass, String[] includedFields )
throws MappingException
{
Collection columns = new ArrayList();
for ( int i = 0; i < includedFields.length; i++ )
{
String propertyName = includedFields[i];
Property property = getMapping( peristentClass ).getProperty( propertyName );
for ( Iterator it = property.getColumnIterator(); it.hasNext(); )
{
Column col = ( Column ) it.next();
columns.add( col.getName() );
}
}
return ( String[] ) columns.toArray( new String[columns.size()] );
}
示例14: testEntityToDatabaseBindingMetadata
import org.hibernate.mapping.Property; //导入依赖的package包/类
@Test
public void testEntityToDatabaseBindingMetadata() {
Metadata metadata = MetadataExtractorIntegrator.INSTANCE.getMetadata();
for ( PersistentClass persistentClass : metadata.getEntityBindings()) {
Table table = persistentClass.getTable();
LOGGER.info( "Entity: {} is mapped to table: {}",
persistentClass.getClassName(),
table.getName()
);
for(Iterator propertyIterator =
persistentClass.getPropertyIterator(); propertyIterator.hasNext(); ) {
Property property = (Property) propertyIterator.next();
for(Iterator columnIterator =
property.getColumnIterator(); columnIterator.hasNext(); ) {
Column column = (Column) columnIterator.next();
LOGGER.info( "Property: {} is mapped on table column: {} of type: {}",
property.getName(),
column.getName(),
column.getSqlType()
);
}
}
}
}
示例15: getNestedInnerComponentNames
import org.hibernate.mapping.Property; //导入依赖的package包/类
public List<String> getNestedInnerComponentNames(String parentClassname, String topLevelComponentName,
String nestedComponentName, String innerComponentNamePrefix) {
List<String> names = new ArrayList<String>();
PersistentClass parent = configuration.getClassMapping(parentClassname);
Property topLevelProperty = parent.getProperty(topLevelComponentName);
Component topLevelComponent = (Component) topLevelProperty.getValue();
Property nestedProperty = topLevelComponent.getProperty(nestedComponentName);
Set nestedSet = (Set) nestedProperty.getValue();
Component nestedComponent = (Component) nestedSet.getElement();
Iterator<?> propertyIter = nestedComponent.getPropertyIterator();
while (propertyIter.hasNext()) {
Property prop = (Property) propertyIter.next();
if (prop.getName().startsWith(innerComponentNamePrefix)) {
names.add(prop.getName());
}
}
return names;
}