项目:lams
文件:JPAOverriddenAnnotationReader.java
private void getMapKeyClass(List<Annotation> annotationList,Element element,XMLContext.Default defaults) {
String nodeName = "map-key-class";
Element subelement = element != null ? element.element( nodeName ) : null;
if ( subelement != null ) {
String mapKeyClassName = subelement.attributeValue( "class" );
AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyClass.class );
if ( StringHelper.isNotEmpty( mapKeyClassName ) ) {
Class clazz;
try {
clazz = ReflectHelper.classForName(
XMLContext.buildSafeClassName( mapKeyClassName,defaults ),this.getClass()
);
}
catch ( ClassNotFoundException e ) {
throw new AnnotationException(
"Unable to find " + element.getPath() + " " + nodeName + ": " + mapKeyClassName,e
);
}
ad.setValue( "value",clazz );
}
annotationList.add( AnnotationFactory.create( ad ) );
}
}
项目:org.fastnate
文件:MapProperty.java
/**
* Creates a new map property.
*
* @param sourceClass
* the description of the current inspected class that contains this property
* @param attribute
* the accessor of the represented attribute
* @param override
* the configured assocation override
*/
@SuppressWarnings("unchecked")
public MapProperty(final EntityClass<?> sourceClass,final AttributeAccessor attribute,final AssociationOverride override) {
super(sourceClass,attribute,override,1);
// Initialize the key description
final MapKeyClass keyClassAnnotation = attribute.getAnnotation(MapKeyClass.class);
this.keyClass = getPropertyArgument(attribute,keyClassAnnotation != null ? keyClassAnnotation.value() : (Class<K>) void.class,0);
this.keyEntityClass = sourceClass.getContext().getDescription(this.keyClass);
if (getMappedBy() != null) {
this.keyConverter = null;
this.keyColumn = null;
} else {
if (this.keyEntityClass != null) {
// Entity key
this.keyConverter = null;
this.keyColumn = buildKeyColumn(getTable(),attribute.getAnnotation(MapKeyJoinColumn.class),attribute.getName() + "_KEY");
} else {
// Primitive key
this.keyConverter = PrimitiveProperty.createConverter(attribute,this.keyClass,true);
this.keyColumn = buildKeyColumn(getTable(),attribute.getAnnotation(MapKeyColumn.class),attribute.getName() + "_KEY");
}
}
}
项目:Jouve-Project
文件:FeaturedLink.java
@ElementCollection(targetClass = String.class)
@CollectionTable(name = "FeaturedLink_Keywords",joinColumns = @JoinColumn(name = "featuredLink_id"))
@MapKeyClass(String.class)
@Column(name="keyword",length = 10 * 1024)
public Set<String> getKeywords() {
return keywords;
}
项目:Jouve-Project
文件:FeaturedLink.java
@ElementCollection(targetClass = String.class)
@CollectionTable(name = "FeaturedLink_KeywordsAnalyzed",length = 10 * 1024)
public Set<String> getKeywordsAnalyzed() {
return keywordsAnalyzed;
}
项目:Jouve-Project
文件:I18NLabel.java
@ElementCollection(targetClass = String.class)
@CollectionTable(name = "I18NLabel_Values")
@MapKeyColumn(name="locale",length = 128)
@MapKeyClass(Locale.class)
@Column(name="value",length = 10 * 1024)
public Map<Locale,String> getValues() {
return values;
}
项目:Jouve-Project
文件:RecordCollection.java
@ElementCollection
@CollectionTable(name = "RecordCollection_Locales",joinColumns = @JoinColumn(name = "recordCollection_id"))
@MapKeyColumn(name = "locale",length = 128)
@MapKeyClass(Locale.class)
public Set<Locale> getLocales() {
return locales;
}
项目:lams
文件:CollectionPropertyHolder.java
public void prepare(XProperty collectionProperty) {
// fugly
if ( prepared ) {
return;
}
if ( collectionProperty == null ) {
return;
}
prepared = true;
if ( collection.isMap() ) {
if ( collectionProperty.isAnnotationPresent( MapKeyEnumerated.class ) ) {
canKeyBeConverted = false;
}
else if ( collectionProperty.isAnnotationPresent( MapKeyTemporal.class ) ) {
canKeyBeConverted = false;
}
else if ( collectionProperty.isAnnotationPresent( MapKeyClass.class ) ) {
canKeyBeConverted = false;
}
else if ( collectionProperty.isAnnotationPresent( MapKeyType.class ) ) {
canKeyBeConverted = false;
}
}
else {
canKeyBeConverted = false;
}
if ( collectionProperty.isAnnotationPresent( ManyToAny.class ) ) {
canElementBeConverted = false;
}
else if ( collectionProperty.isAnnotationPresent( OnetoMany.class ) ) {
canElementBeConverted = false;
}
else if ( collectionProperty.isAnnotationPresent( ManyToMany.class ) ) {
canElementBeConverted = false;
}
else if ( collectionProperty.isAnnotationPresent( Enumerated.class ) ) {
canElementBeConverted = false;
}
else if ( collectionProperty.isAnnotationPresent( Temporal.class ) ) {
canElementBeConverted = false;
}
else if ( collectionProperty.isAnnotationPresent( CollectionType.class ) ) {
canElementBeConverted = false;
}
// Is it valid to reference a collection attribute in a @Convert attached to the owner (entity) by path?
// if so we should pass in 'clazzToProcess' also
if ( canKeyBeConverted || canElementBeConverted ) {
buildAttributeConversionInfoMaps( collectionProperty,elementAttributeConversionInfoMap,keyAttributeConversionInfoMap );
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。