@Entity @TypeDef(defaultForType = SimpleDoubleScore.class, typeClass = SimpleDoubleScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<SimpleDoubleScore> { protected SimpleDoubleScore score; private TestJpaEntity() { } public TestJpaEntity(SimpleDoubleScore score) { this.score = score; } @Override @Columns(columns = {@Column(name = "initScore"), @Column(name = "score")}) public SimpleDoubleScore getScore() { return score; } @Override public void setScore(SimpleDoubleScore score) { this.score = score; } }
private static void bindTypeDef(TypeDef defAnn, MetadataBuildingContext context) { Properties params = new Properties(); for ( Parameter param : defAnn.parameters() ) { params.setProperty( param.name(), param.value() ); if ( BinderHelper.isEmptyAnnotationValue( defAnn.name() ) && defAnn.defaultForType().equals( void.class ) ) { throw new AnnotationException( "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " + defAnn.typeClass().getName() ); if ( !BinderHelper.isEmptyAnnotationValue( defAnn.name() ) ) { if ( LOG.isDebugEnabled() ) { LOG.debugf( typeBindMessageF, defAnn.name() ); defAnn.name(), defAnn.typeClass(), null, params if ( !defAnn.defaultForType().equals( void.class ) ) { if ( LOG.isDebugEnabled() ) { LOG.debugf( typeBindMessageF, defAnn.defaultForType().getName() ); defAnn.defaultForType().getName(), defAnn.typeClass(), new String[]{ defAnn.defaultForType().getName() }, params
private static void bindTypeDef(TypeDef defAnn, ExtendedMappings mappings) { Properties params = new Properties(); for ( Parameter param : defAnn.parameters() ) { params.setProperty( param.name(), param.value() ); } if ( log.isInfoEnabled() ) log.info( "Binding type definition: " + defAnn.name() ); mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params ); }
@Entity @TypeDef(defaultForType = HardSoftDoubleScore.class, typeClass = HardSoftDoubleScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<HardSoftDoubleScore> { protected HardSoftDoubleScore score; private TestJpaEntity() { } public TestJpaEntity(HardSoftDoubleScore score) { this.score = score; } @Override @Columns(columns = {@Column(name = "initScore"), @Column(name = "hardScore"), @Column(name = "softScore")}) public HardSoftDoubleScore getScore() { return score; } @Override public void setScore(HardSoftDoubleScore score) { this.score = score; } }
private static void bindTypeDef(TypeDef defAnn, ExtendedMappings mappings) { Properties params = new Properties(); for ( Parameter param : defAnn.parameters() ) { params.setProperty( param.name(), param.value() ); } if ( BinderHelper.isDefault( defAnn.name() ) && defAnn.defaultForType().equals( void.class ) ) { throw new AnnotationException( "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " + defAnn.typeClass().getName() ); } if ( !BinderHelper.isDefault( defAnn.name() ) ) { log.info( "Binding type definition: {}", defAnn.name() ); mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params ); } if ( !defAnn.defaultForType().equals( void.class ) ) { log.info( "Binding type definition: {}", defAnn.defaultForType().getName() ); mappings.addTypeDef( defAnn.defaultForType().getName(), defAnn.typeClass().getName(), params ); } }
@Entity @TypeDef(defaultForType = HardSoftLongScore.class, typeClass = HardSoftLongScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<HardSoftLongScore> { protected HardSoftLongScore score; private TestJpaEntity() { } public TestJpaEntity(HardSoftLongScore score) { this.score = score; } @Override @Columns(columns = {@Column(name = "initScore"), @Column(name = "hardScore"), @Column(name = "softScore")}) public HardSoftLongScore getScore() { return score; } @Override public void setScore(HardSoftLongScore score) { this.score = score; } }
private static void bindTypeDef(TypeDef defAnn, Mappings mappings) { Properties params = new Properties(); for ( Parameter param : defAnn.parameters() ) { params.setProperty( param.name(), param.value() ); } if ( BinderHelper.isEmptyAnnotationValue( defAnn.name() ) && defAnn.defaultForType().equals( void.class ) ) { throw new AnnotationException( "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " + defAnn.typeClass().getName() ); } final String typeBindMessageF = "Binding type definition: %s"; if ( !BinderHelper.isEmptyAnnotationValue( defAnn.name() ) ) { if ( LOG.isDebugEnabled() ) { LOG.debugf( typeBindMessageF, defAnn.name() ); } mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params ); } if ( !defAnn.defaultForType().equals( void.class ) ) { if ( LOG.isDebugEnabled() ) { LOG.debugf( typeBindMessageF, defAnn.defaultForType().getName() ); } mappings.addTypeDef( defAnn.defaultForType().getName(), defAnn.typeClass().getName(), params ); } }
@Entity @TypeDef(defaultForType = SimpleLongScore.class, typeClass = SimpleLongScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<SimpleLongScore> { protected SimpleLongScore score; private TestJpaEntity() { } public TestJpaEntity(SimpleLongScore score) { this.score = score; } @Override @Columns(columns = {@Column(name = "initScore"), @Column(name = "score")}) public SimpleLongScore getScore() { return score; } @Override public void setScore(SimpleLongScore score) { this.score = score; } }
private static void bindTypeDef(TypeDef defAnn, Mappings mappings) { Properties params = new Properties(); for ( Parameter param : defAnn.parameters() ) { params.setProperty( param.name(), param.value() ); } if ( BinderHelper.isEmptyAnnotationValue( defAnn.name() ) && defAnn.defaultForType().equals( void.class ) ) { throw new AnnotationException( "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " + defAnn.typeClass().getName() ); } final String typeBindMessageF = "Binding type definition: %s"; if ( !BinderHelper.isEmptyAnnotationValue( defAnn.name() ) ) { if ( LOG.isDebugEnabled() ) { LOG.debugf( typeBindMessageF, defAnn.name() ); } mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params ); } if ( !defAnn.defaultForType().equals( void.class ) ) { if ( LOG.isDebugEnabled() ) { LOG.debugf( typeBindMessageF, defAnn.defaultForType().getName() ); } mappings.addTypeDef( defAnn.defaultForType().getName(), defAnn.typeClass().getName(), params ); } }
@Entity @TypeDef(defaultForType = HardSoftScore.class, typeClass = HardSoftScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<HardSoftScore> { protected HardSoftScore score; private TestJpaEntity() { } public TestJpaEntity(HardSoftScore score) { this.score = score; } @Override @Columns(columns = {@Column(name = "initScore"), @Column(name = "hardScore"), @Column(name = "softScore")}) public HardSoftScore getScore() { return score; } @Override public void setScore(HardSoftScore score) { this.score = score; } }
private static void bindTypeDef(TypeDef defAnn, MetadataBuildingContext context) { Properties params = new Properties(); for ( Parameter param : defAnn.parameters() ) { params.setProperty( param.name(), param.value() ); if ( BinderHelper.isEmptyAnnotationValue( defAnn.name() ) && defAnn.defaultForType().equals( void.class ) ) { throw new AnnotationException( "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " + defAnn.typeClass().getName() ); if ( !BinderHelper.isEmptyAnnotationValue( defAnn.name() ) ) { if ( LOG.isDebugEnabled() ) { LOG.debugf( typeBindMessageF, defAnn.name() ); defAnn.name(), defAnn.typeClass(), null, params, if ( !defAnn.defaultForType().equals( void.class ) ) { if ( LOG.isDebugEnabled() ) { LOG.debugf( typeBindMessageF, defAnn.defaultForType().getName() ); defAnn.defaultForType().getName(), defAnn.typeClass(), new String[] { defAnn.defaultForType().getName() }, params, context.getBootstrapContext().getTypeConfiguration()
@Entity @TypeDef(defaultForType = SimpleBigDecimalScore.class, typeClass = SimpleBigDecimalScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<SimpleBigDecimalScore> { protected SimpleBigDecimalScore score; private TestJpaEntity() { } public TestJpaEntity(SimpleBigDecimalScore score) { this.score = score; } @Override @Columns(columns = {@Column(name = "initScore"), @Column(name = "score", precision = 10, scale = 5)}) public SimpleBigDecimalScore getScore() { return score; } @Override public void setScore(SimpleBigDecimalScore score) { this.score = score; } }
@Entity @TypeDef(defaultForType = SimpleScore.class, typeClass = SimpleScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<SimpleScore> { protected SimpleScore score; private TestJpaEntity() { } public TestJpaEntity(SimpleScore score) { this.score = score; } @Override @Columns(columns = {@Column(name = "initScore"), @Column(name = "score")}) public SimpleScore getScore() { return score; } @Override public void setScore(SimpleScore score) { this.score = score; } }
@Entity @TypeDef(defaultForType = HardMediumSoftLongScore.class, typeClass = HardMediumSoftLongScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<HardMediumSoftLongScore> { protected HardMediumSoftLongScore score; private TestJpaEntity() { } public TestJpaEntity(HardMediumSoftLongScore score) { this.score = score; } @Override @Columns(columns = {@Column(name = "initScore"), @Column(name = "hardScore"), @Column(name = "mediumScore"), @Column(name = "softScore")}) public HardMediumSoftLongScore getScore() { return score; } @Override public void setScore(HardMediumSoftLongScore score) { this.score = score; } }
@Entity @TypeDef(defaultForType = HardMediumSoftScore.class, typeClass = HardMediumSoftScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<HardMediumSoftScore> { protected HardMediumSoftScore score; private TestJpaEntity() { } public TestJpaEntity(HardMediumSoftScore score) { this.score = score; } @Override @Columns(columns = {@Column(name = "initScore"), @Column(name = "hardScore"), @Column(name = "mediumScore"), @Column(name = "softScore")}) public HardMediumSoftScore getScore() { return score; } @Override public void setScore(HardMediumSoftScore score) { this.score = score; } }
@Entity @TypeDef(defaultForType = HardSoftBigDecimalScore.class, typeClass = HardSoftBigDecimalScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<HardSoftBigDecimalScore> { protected HardSoftBigDecimalScore score; private TestJpaEntity() { } public TestJpaEntity(HardSoftBigDecimalScore score) { this.score = score; } @Override @Columns(columns = { @Column(name = "initScore"), @Column(name = "hardScore", precision = 10, scale = 5), @Column(name = "softScore", precision = 10, scale = 5)}) public HardSoftBigDecimalScore getScore() { return score; } @Override public void setScore(HardSoftBigDecimalScore score) { this.score = score; } }
@Entity(name = "Product") @TypeDef( name = "bitset", defaultForType = BitSet.class, typeClass = BitSetType.class ) public static class Product { @Id private Integer id; private BitSet bitSet; //Getters and setters are omitted for brevity //end::basic-custom-type-BitSetTypeDef-mapping-example[] public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public BitSet getBitSet() { return bitSet; } public void setBitSet(BitSet bitSet) { this.bitSet = bitSet; } //tag::basic-custom-type-BitSetTypeDef-mapping-example[] } //end::basic-custom-type-BitSetTypeDef-mapping-example[]
@Entity @TypeDef(defaultForType = HardMediumSoftBigDecimalScore.class, typeClass = HardMediumSoftBigDecimalScoreHibernateType.class) public static class TestJpaEntity extends AbstractTestJpaEntity<HardMediumSoftBigDecimalScore> { protected HardMediumSoftBigDecimalScore score; private TestJpaEntity() { } public TestJpaEntity(HardMediumSoftBigDecimalScore score) { this.score = score; } @Override @Columns(columns = { @Column(name = "initScore"), @Column(name = "hardScore", precision = 10, scale = 5), @Column(name = "mediumScore", precision = 10, scale = 5), @Column(name = "softScore", precision = 10, scale = 5)}) public HardMediumSoftBigDecimalScore getScore() { return score; } @Override public void setScore(HardMediumSoftBigDecimalScore score) { this.score = score; } }
/** * @author Vlad Mihalcea */ @Entity(name = "Person") @TypeDef( name = "comma_delimited_strings", typeClass = CommaDelimitedStringsType.class) public class PersonPhone { @Id private Long id; @Type(type = "comma_delimited_strings") private List<Phone> phones = new ArrayList<>(); public List<Phone> getPhones() { return phones; } }
/** * @author Vlad Mihalcea */ @Entity(name = "Person") @TypeDef( name = "comma_delimited_strings", typeClass = CommaDelimitedStringsType.class) public class Person { @Id private Long id; @Type(type = "comma_delimited_strings") private List<String> phones = new ArrayList<>(); public List<String> getPhones() { return phones; } }