本文整理汇总了Java中javax.persistence.MapsId类的典型用法代码示例。如果您正苦于以下问题:Java MapsId类的具体用法?Java MapsId怎么用?Java MapsId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapsId类属于javax.persistence包,在下文中一共展示了MapsId类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIdColumn
import javax.persistence.MapsId; //导入依赖的package包/类
/**
* Resolves the column for the {@code id property} of this entity class.
*
* @param attribute
* the referencing attribute (for evaluating annotations)
*
* @return the column name
* @throws IllegalStateException
* if the id property is not singular and no MapsId is given
*/
GeneratorColumn getIdColumn(final AttributeAccessor attribute) {
if (this.idProperty instanceof SingularProperty) {
return ((SingularProperty<?, ?>) this.idProperty).getColumn();
}
if (this.idProperty instanceof EmbeddedProperty) {
final MapsId mapsId = attribute.getAnnotation(MapsId.class);
if (mapsId != null && mapsId.value().length() > 0) {
final Property<?, ?> property = ((EmbeddedProperty<E, ?>) this.idProperty).getEmbeddedProperties()
.get(mapsId.value());
if (property instanceof SingularProperty) {
return ((SingularProperty<?, ?>) this.idProperty).getColumn();
}
}
throw new ModelException(attribute + " misses MapId for a singular property in " + this.entityClass);
}
if (this.idProperty == null && this.parentEntityClass != null) {
// It seems we are still building the hierarchy
this.idProperty = this.context.getDescription(this.parentEntityClass).getIdProperty();
if (this.idProperty != null) {
return getIdColumn(attribute);
}
}
throw new ModelException(attribute + " does not reference an ID column in " + this.entityClass);
}
示例2: addPropertyAnnotatedWithMapsId
import javax.persistence.MapsId; //导入依赖的package包/类
public void addPropertyAnnotatedWithMapsId(XClass entityType, PropertyData property) {
Map<String, PropertyData> map = propertiesAnnotatedWithMapsId.get( entityType );
if ( map == null ) {
map = new HashMap<String, PropertyData>();
propertiesAnnotatedWithMapsId.put( entityType, map );
}
map.put( property.getProperty().getAnnotation( MapsId.class ).value(), property );
}
示例3: getMapsId
import javax.persistence.MapsId; //导入依赖的package包/类
/**
* Adds a @MapsId annotation to the specified annotationList if the specified element has the
* maps-id attribute set. This should only be the case for many-to-one or one-to-one
* associations.
*/
private void getMapsId(List<Annotation> annotationList, Element element) {
String attrVal = element.attributeValue( "maps-id" );
if ( attrVal != null ) {
AnnotationDescriptor ad = new AnnotationDescriptor( MapsId.class );
ad.setValue( "value", attrVal );
annotationList.add( AnnotationFactory.create( ad ) );
}
}
示例4: getRecord
import javax.persistence.MapsId; //导入依赖的package包/类
@ForeignKey(name = "none")
@MapsId("record")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name = COLUMN_RECORD_ID, referencedColumnName = "id")
})
public RAuditEventRecord getRecord() {
return record;
}
示例5: EntityProperty
import javax.persistence.MapsId; //导入依赖的package包/类
/**
* Creates a new instance of {@link EntityProperty}.
*
* @param context
* the generator context.
* @param containerTable
* the table that contains our column
* @param attribute
* the accessor of the attribute
* @param override
* optional {@link AttributeOverride} configuration.
*/
public EntityProperty(final GeneratorContext context, final GeneratorTable containerTable,
final AttributeAccessor attribute, @Nullable final AssociationOverride override) {
super(attribute);
this.context = context;
// Initialize the target class description
this.targetClass = context.getDescription((Class<T>) attribute.getType());
// Initialize according to the *ToOne annotations
final MappingInformation mapping = new MappingInformation(attribute);
this.required = !mapping.isOptional();
this.mappedBy = mapping.getMappedBy().length() == 0 ? null : mapping.getMappedBy();
final MapsId mapsId = attribute.getAnnotation(MapsId.class);
this.idField = mapsId != null ? mapsId.value() : null;
// Initialize the column name
if (this.mappedBy == null) {
final JoinColumn joinColumn = override != null && override.joinColumns().length > 0
? override.joinColumns()[0]
: attribute.getAnnotation(JoinColumn.class);
if (joinColumn != null && joinColumn.name().length() > 0) {
this.column = containerTable.resolveColumn(joinColumn.name());
} else {
this.column = containerTable.resolveColumn(attribute.getName() + "_"
+ (this.targetClass == null ? "id" : this.targetClass.getIdColumn(attribute)));
}
} else {
this.column = null;
}
// Initialize ANY meta information
final String anyColumnName = mapping.getAnyMetaColumn();
if (anyColumnName != null) {
this.anyColumn = containerTable.resolveColumn(anyColumnName);
fillMetaDefs(attribute, context.getDialect());
} else {
this.anyColumn = null;
}
}
示例6: getModelRatingResults
import javax.persistence.MapsId; //导入依赖的package包/类
@MapsId("processId")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PROCESS_ID", insertable = false, updatable = false)
public ModelRatingResults getModelRatingResults() {
return this.modelRatingResults;
}
示例7:
import javax.persistence.MapsId; //导入依赖的package包/类
@JoinColumn(name = "ID2", nullable = false)
@ManyToOne
@MapsId(value = "id2")
public UseCase2 getId2() {
return id2;
}
示例8: findMappedId
import javax.persistence.MapsId; //导入依赖的package包/类
private static String findMappedId(final AttributeAccessor attribute) {
final MapsId mapsId = attribute.getAnnotation(MapsId.class);
return mapsId == null || mapsId.value().length() == 0 ? null : mapsId.value();
}
示例9: isMapsId
import javax.persistence.MapsId; //导入依赖的package包/类
/**
* Return true if MapsId annotation is define on a field.
* @param field the field
* @return true/false.
*/
public static boolean isMapsId(final Field field) {
return field.getAnnotation(MapsId.class) != null;
}
示例10: getMapsIdValue
import javax.persistence.MapsId; //导入依赖的package包/类
/**
* Get field name from MapsId annotation.
* @param field the field
* @return the field name.
*/
public static String getMapsIdValue(final Field field) {
final MapsId m = field.getAnnotation(MapsId.class);
return m == null ? null : m.value();
}