Java Code Examples for javax.persistence.Lob

The following examples show how to use javax.persistence.Lob. These examples are extracted from open source projects. 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 Project: bdf3   Source File: AbstractCellPostParser.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void parse(Context context) {
	if (context.getValue() != null) {
		MappingRule mappingRule =context.getCurrentMappingRule();
		BeanMap beanMap = BeanMap.create(context.getCurrentEntity());
		if (context.getValue() != Constants.IGNORE_ERROR_FORMAT_DATA) {
			Field field = ReflectionUtils.findField(context.getEntityClass(), mappingRule.getPropertyName());
			Column column = field.getAnnotation(Column.class);
			if (column.nullable()) {
				if (context.getValue() == null) {
					throw new DataNullableException(context.getCurrentCell().getRow(), context.getCurrentCell().getCol());
				}
			}
			
			if (field.getType() == String.class && !field.isAnnotationPresent(Lob.class)) {
				String value = (String) context.getValue();
				if (value.getBytes().length > column.length()) {
					throw new DataLengthException(context.getCurrentCell().getRow(), context.getCurrentCell().getCol(), value, column.length());
				}
			}
			beanMap.put(mappingRule.getPropertyName(), context.getValue());
		}
	}
}
 
Example 2
Source Project: mPaaS   Source File: FdContent.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 读-文档内容
 *
 * @return
 */
@Column
@Lob
@MetaProperty(messageKey = "property.fdContent")
default String getFdContent() {
    return (String) getExtendProps().get("fdContent");
}
 
Example 3
Source Project: o2oa   Source File: CheckCore.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static void checkLobIndex(List<Class<?>> classes) throws Exception {
	for (Class<?> cls : classes) {
		List<Field> fields = FieldUtils.getAllFieldsList(cls);
		for (Field field : fields) {
			Lob lob = field.getAnnotation(Lob.class);
			Index index = field.getAnnotation(Index.class);
			if ((null != lob) && (null != index)) {
				System.err.println(String.format("checkLobIndex error: class: %s, field: %s.", cls.getName(),
						field.getName()));
			}
		}
	}
}
 
Example 4
private void createStringLobField(Builder builder, Field field) {

//		public static final String stringLobValue_FIELDNAME = "stringLobValue";
//		@FieldDescribe("长文本.")
//		@Lob
//		@Basic(fetch = FetchType.EAGER)
//		@Column(length = JpaObject.length_10M, name = ColumnNamePrefix + stringLobValue_FIELDNAME)

		AnnotationSpec lob = AnnotationSpec.builder(Lob.class).build();

		AnnotationSpec basic = AnnotationSpec.builder(Basic.class)
				.addMember("fetch", "javax.persistence.FetchType.EAGER").build();

		AnnotationSpec column = AnnotationSpec.builder(Column.class).addMember("length", "length_100M")
				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();

		FieldSpec fieldSpec = FieldSpec.builder(String.class, field.getName(), Modifier.PRIVATE)
				.addAnnotation(this.fieldDescribe(field)).addAnnotation(lob).addAnnotation(basic).addAnnotation(column)
				.build();
		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
				.addModifiers(Modifier.PUBLIC).returns(String.class).addStatement("return this." + field.getName())
				.build();
		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(String.class, field.getName())
				.addStatement("this." + field.getName() + " = " + field.getName()).build();
		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);

	}
 
Example 5
@Override
public Optional<Boolean> isFilterable(BeanAttributeInformation attributeDesc) {
    Optional<Lob> lob = attributeDesc.getAnnotation(Lob.class);
    if (lob.isPresent()) {
        return Optional.of(false);
    }
    return Optional.empty();
}
 
Example 6
Source Project: jump-the-queue   Source File: BinaryObjectEntity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return the {@link Blob} data.
 */
@Lob
@Column(name = "content")
public Blob getData() {

  return this.data;
}
 
Example 7
@Override
public JdbcType getJdbcType() {

	if (isAnnotationPresent(
			org.springframework.data.mybatis.annotation.JdbcType.class)) {
		return JdbcType.valueOf(getRequiredAnnotation(
				org.springframework.data.mybatis.annotation.JdbcType.class).value());
	}

	if (isAnnotationPresent(Temporal.class)) {
		Temporal temporal = getRequiredAnnotation(Temporal.class);
		switch (temporal.value()) {

		case DATE:
			return DATE;
		case TIME:
			return TIME;
		case TIMESTAMP:
			return TIMESTAMP;
		}
	}

	Class<?> actualType = getActualType();

	if (isAnnotationPresent(Lob.class)) {
		if (actualType == String.class) {
			return CLOB;
		}
		return BLOB;
	}

	JdbcType jdbcType = JAVA_MAPPED_TO_JDBC_TYPES.get(actualType);

	return null == jdbcType ? UNDEFINED : jdbcType;
}
 
Example 8
Source Project: jeewx   Source File: JeecgDemoCkfinderEntity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 方法: 取得java.lang.Object
 * 
 * @return: java.lang.Object 备注
 */
@Lob
@Basic(fetch = FetchType.LAZY)
@Column(name = "REMARK", nullable = true)
public java.lang.String getRemark() {
	return this.remark;
}
 
Example 9
Source Project: cia   Source File: CommitteeProposalData.java    License: Apache License 2.0 5 votes vote down vote up
/**
* Gets the ballot summary item.
*
* @return the ballot summary item
*/
  @Basic
  @Column(name = "BALLOT_SUMMARY_ITEM")
  @Lob
  public String getBallotSummaryItem() {
      return XmlAdapterUtils.unmarshall(ElementAsString.class, this.getBallotSummary());
  }
 
Example 10
Source Project: olingo-odata2   Source File: JPATypeConverter.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isBlob(final Attribute<?, ?> currentAttribute) {
  if (currentAttribute != null) {
    AnnotatedElement annotatedElement = (AnnotatedElement) currentAttribute.getJavaMember();
    if (annotatedElement != null && annotatedElement.getAnnotation(Lob.class) != null) {
      return true;
    }
  }
  return false;
}
 
Example 11
Source Project: olingo-odata2   Source File: JPATypeConverterTest.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) {

  if (testCase.equals("temporalnull")) {
    return null;
  }

  if (annotationClass.equals(Temporal.class)) {
    if (temporal == null) {
      temporal = EasyMock.createMock(Temporal.class);
      if (testCase.equals("datetime")) {
        EasyMock.expect(temporal.value()).andReturn(TemporalType.TIMESTAMP).anyTimes();
        EasyMock.replay(temporal);
      } else if (testCase.equals("time")) {
        EasyMock.expect(temporal.value()).andReturn(TemporalType.TIME).anyTimes();
        EasyMock.replay(temporal);
      }
    }
    return (T) temporal;
  } else if (annotationClass.equals(Lob.class)) {
    if (testCase.equals("lob")) {
      lob = EasyMock.createMock(Lob.class);
      EasyMock.replay(lob);
    }
    return (T) lob;
  }
  return null;

}
 
Example 12
Source Project: ankush   Source File: NodeMonitoring.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @return the graphView
 */
@JsonIgnore
@Lob
@Column(length = Integer.MAX_VALUE - 1)
public byte[] getGraphView() {
	return graphView;
}
 
Example 13
Source Project: ankush   Source File: NodeMonitoring.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @return the technologyServiceBytes
 */
@JsonIgnore
@Lob
@Column(length = Integer.MAX_VALUE - 1)
public byte[] getTechnologyServiceBytes() {
	return technologyServiceBytes;
}
 
Example 14
Source Project: ankush   Source File: Template.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @return the dataBytes
 */
@JsonIgnore
@Lob
@Column(length = Integer.MAX_VALUE - 1)
public byte[] getDataBytes() {
	return dataBytes;
}
 
Example 15
Source Project: we-cmdb   Source File: AdmOperateRecord.java    License: Apache License 2.0 4 votes vote down vote up
@Lob
@Column(name = "json_obj_str")
public String getJsonObjStr() {
    return this.jsonObjStr;
}
 
Example 16
Source Project: we-cmdb   Source File: AdmLog.java    License: Apache License 2.0 4 votes vote down vote up
@Lob
@Column(name = "log_content")
public String getLogContent() {
    return this.logContent;
}
 
Example 17
Source Project: we-cmdb   Source File: VersionAttr.java    License: Apache License 2.0 4 votes vote down vote up
@Lob
public String getV() {
    return this.v;
}
 
Example 18
Source Project: jeecg   Source File: CgformFtlEntity.java    License: Apache License 2.0 4 votes vote down vote up
/**
 *方法: 取得
 *@return:   表单模板内容
 */
@Lob
@Column(name ="FTL_CONTENT",nullable=true)
public String getFtlContent(){
	return this.ftlContent;
}
 
Example 19
Source Project: Quelea   Source File: Song.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Lob
@Column(name="translations", length=STRING_LENGTH)
public HashMap<String, String> getTranslations() {
    return translations;
}
 
Example 20
Source Project: crnk-framework   Source File: AbstractEntityMetaFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void initAttribute(MetaAttribute attr) {
	ManyToMany manyManyAnnotation = attr.getAnnotation(ManyToMany.class);
	ManyToOne manyOneAnnotation = attr.getAnnotation(ManyToOne.class);
	OneToMany oneManyAnnotation = attr.getAnnotation(OneToMany.class);
	OneToOne oneOneAnnotation = attr.getAnnotation(OneToOne.class);
	Version versionAnnotation = attr.getAnnotation(Version.class);
	Lob lobAnnotation = attr.getAnnotation(Lob.class);
	Column columnAnnotation = attr.getAnnotation(Column.class);

	boolean idAttr = attr.getAnnotation(Id.class) != null || attr.getAnnotation(EmbeddedId.class) != null;
	boolean attrGenerated = attr.getAnnotation(GeneratedValue.class) != null;

	attr.setVersion(versionAnnotation != null);
	attr.setAssociation(
			manyManyAnnotation != null || manyOneAnnotation != null || oneManyAnnotation != null || oneOneAnnotation !=
					null);

	attr.setLazy(isJpaLazy(attr.getAnnotations(), attr.isAssociation()));
	attr.setLob(lobAnnotation != null);
	attr.setFilterable(lobAnnotation == null);
	attr.setSortable(lobAnnotation == null);

	attr.setCascaded(getCascade(manyManyAnnotation, manyOneAnnotation, oneManyAnnotation, oneOneAnnotation));

	if (attr.getReadMethod() == null) {
		throw new IllegalStateException("no getter found for " + attr.getParent().getName() + "." + attr.getName());
	}
	Class<?> attributeType = attr.getReadMethod().getReturnType();
	boolean isPrimitiveType = ClassUtils.isPrimitiveType(attributeType);
	boolean columnNullable = (columnAnnotation == null || columnAnnotation.nullable()) &&
			(manyOneAnnotation == null || manyOneAnnotation.optional()) &&
			(oneOneAnnotation == null || oneOneAnnotation.optional());
	attr.setNullable(!isPrimitiveType && columnNullable);

	boolean hasSetter = attr.getWriteMethod() != null;
	attr.setInsertable(hasSetter && (columnAnnotation == null || columnAnnotation.insertable()) && !attrGenerated
			&& versionAnnotation == null);
	attr.setUpdatable(
			hasSetter && (columnAnnotation == null || columnAnnotation.updatable()) && !idAttr && versionAnnotation == null);

}
 
Example 21
Source Project: jeecg   Source File: TSAttachment.java    License: Apache License 2.0 4 votes vote down vote up
@Column(name = "attachmentcontent",length=3000)
@Lob
public byte[] getAttachmentcontent() {
	return this.attachmentcontent;
}
 
Example 22
private void getLob(List<Annotation> annotationList, Element element) {
	Element subElement = element != null ? element.element( "lob" ) : null;
	if ( subElement != null ) {
		annotationList.add( AnnotationFactory.create( new AnnotationDescriptor( Lob.class ) ) );
	}
}
 
Example 23
Source Project: lams   Source File: PropertyBinder.java    License: GNU General Public License v2.0 4 votes vote down vote up
public Property makeProperty() {
	validateMake();
	LOG.debugf( "Building property %s", name );
	Property prop = new Property();
	prop.setName( name );
	prop.setValue( value );
	prop.setLazy( lazy );
	prop.setLazyGroup( lazyGroup );
	prop.setCascade( cascade );
	prop.setPropertyAccessorName( accessType.getType() );

	if ( property != null ) {
		prop.setValueGenerationStrategy( determineValueGenerationStrategy( property ) );

		if ( property.isAnnotationPresent( AttributeAccessor.class ) ) {
			final AttributeAccessor accessor = property.getAnnotation( AttributeAccessor.class );
			prop.setPropertyAccessorName( accessor.value() );
		}
	}

	NaturalId naturalId = property != null ? property.getAnnotation( NaturalId.class ) : null;
	if ( naturalId != null ) {
		if ( ! entityBinder.isRootEntity() ) {
			throw new AnnotationException( "@NaturalId only valid on root entity (or its @MappedSuperclasses)" );
		}
		if ( ! naturalId.mutable() ) {
			updatable = false;
		}
		prop.setNaturalIdentifier( true );
	}

	// HHH-4635 -- needed for dialect-specific property ordering
	Lob lob = property != null ? property.getAnnotation( Lob.class ) : null;
	prop.setLob( lob != null );

	prop.setInsertable( insertable );
	prop.setUpdateable( updatable );

	// this is already handled for collections in CollectionBinder...
	if ( Collection.class.isInstance( value ) ) {
		prop.setOptimisticLocked( ( (Collection) value ).isOptimisticLocked() );
	}
	else {
		final OptimisticLock lockAnn = property != null
				? property.getAnnotation( OptimisticLock.class )
				: null;
		if ( lockAnn != null ) {
			//TODO this should go to the core as a mapping validation checking
			if ( lockAnn.excluded() && (
					property.isAnnotationPresent( javax.persistence.Version.class )
							|| property.isAnnotationPresent( Id.class )
							|| property.isAnnotationPresent( EmbeddedId.class ) ) ) {
				throw new AnnotationException(
						"@OptimisticLock.exclude=true incompatible with @Id, @EmbeddedId and @Version: "
								+ StringHelper.qualify( holder.getPath(), name )
				);
			}
		}
		final boolean isOwnedValue = !isToOneValue( value ) || insertable; // && updatable as well???
		final boolean includeInOptimisticLockChecks = ( lockAnn != null )
				? ! lockAnn.excluded()
				: isOwnedValue;
		prop.setOptimisticLocked( includeInOptimisticLockChecks );
	}

	LOG.tracev( "Cascading {0} with {1}", name, cascade );
	this.mappingProperty = prop;
	return prop;
}
 
Example 24
Source Project: tianti   Source File: Article.java    License: Apache License 2.0 4 votes vote down vote up
@Lob
public String getContent() {
	return content;
}
 
Example 25
Source Project: celerio-angular-quickstart   Source File: Book.java    License: Apache License 2.0 4 votes vote down vote up
@Basic(fetch = LAZY)
@Column(name = "EXTRACT_BINARY")
@Lob
public byte[] getExtractBinary() {
    return extractBinary;
}
 
Example 26
Source Project: jeewx   Source File: CgformFtlEntity.java    License: Apache License 2.0 4 votes vote down vote up
/**
 *方法: 取得byte[]
 *@return: byte[]  表单模板内容
 */
@Lob
@Column(name ="FTL_CONTENT",nullable=true)
public String getFtlContent(){
	return this.ftlContent;
}
 
Example 27
Source Project: jeewx   Source File: TSAttachment.java    License: Apache License 2.0 4 votes vote down vote up
@Column(name = "attachmentcontent",length=3000)
@Lob
public byte[] getAttachmentcontent() {
	return this.attachmentcontent;
}
 
Example 28
Source Project: oval   Source File: JPAAnnotationsConfigurer.java    License: Eclipse Public License 2.0 4 votes vote down vote up
protected void initializeChecks(final Column annotation, final Collection<Check> checks, final AccessibleObject fieldOrMethod) {
   /* If the value is generated (annotated with @GeneratedValue) it is allowed to be null
    * before the entity has been persisted, same is true in case of optimistic locking
    * when a field is annotated with @Version.
    * Therefore and because of the fact that there is no generic way to determine if an entity
    * has been persisted already, a not-null check will not be performed for such fields.
    */
   if (!annotation.nullable() //
      && !fieldOrMethod.isAnnotationPresent(GeneratedValue.class) //
      && !fieldOrMethod.isAnnotationPresent(Version.class) //
      && !fieldOrMethod.isAnnotationPresent(NotNull.class) //
      && !containsCheckOfType(checks, NotNullCheck.class) //
   ) {
      checks.add(new NotNullCheck());
   }

   // add Length check based on Column.length parameter, but only:
   if (!fieldOrMethod.isAnnotationPresent(Lob.class) && // if @Lob is not present
      !fieldOrMethod.isAnnotationPresent(Enumerated.class) && // if @Enumerated is not present
      !fieldOrMethod.isAnnotationPresent(Length.class) // if an explicit @Length constraint is not present
   ) {
      final LengthCheck lengthCheck = new LengthCheck();
      lengthCheck.setMax(annotation.length());
      checks.add(lengthCheck);
   }

   // add Range check based on Column.precision/scale parameters, but only:
   if (!fieldOrMethod.isAnnotationPresent(Range.class) // if an explicit @Range is not present
      && annotation.precision() > 0 // if precision is > 0
      && Number.class.isAssignableFrom(fieldOrMethod instanceof Field //
         ? ((Field) fieldOrMethod).getType() //
         : ((Method) fieldOrMethod).getReturnType()) // if numeric field type
   ) {
      /* precision = 6, scale = 2  => -9999.99<=x<=9999.99
       * precision = 4, scale = 1  =>   -999.9<=x<=999.9
       */
      final RangeCheck rangeCheck = new RangeCheck();
      rangeCheck.setMax(Math.pow(10, annotation.precision() - annotation.scale()) - Math.pow(0.1, annotation.scale()));
      rangeCheck.setMin(-1 * rangeCheck.getMax());
      checks.add(rangeCheck);
   }
}
 
Example 29
Source Project: sample-java-spring-genericdao   Source File: Student.java    License: Apache License 2.0 4 votes vote down vote up
@Lob
@Column(name = "STUDENT_PHOTO")
public byte[] getPhoto() {
	return this.picture;
}
 
Example 30
Source Project: sample-java-spring-genericdao   Source File: Instructor.java    License: Apache License 2.0 4 votes vote down vote up
@Lob
@Column(name = "INSTRUCTOR_RESUME", nullable = false)
public char[]  getResume() {
	return this.resume;
}