hibernate-annotations.jar(3.2.1.GA) from JBoss 4.2.1.GA
I've also tried this with hibernate-validator-3.0.0.jar and hibernate-annotations-3.3.0.jar
Code:
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.validator.apply_to_ddl" value="false"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
....
</properties>
Mapping:
Code:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract static class BaseAbstract extends BaseNamedEntity
{
public BaseAbstract()
{}
protected Integer prop;
public Integer getProp()
{
return prop;
}
public void setProp( Integer prop )
{
this.prop = prop;
}
}
@Entity
public static class Child1 extends BaseAbstract
{
public Child1()
{
}
@Override
@Range( min = 2, max = 5 )
public Integer getProp()
{
return prop;
}
}
@Entity
public static class Child2 extends BaseAbstract
{
public Child2()
{
}
@Range( min = 6, max = 10 )
public Integer getProp()
{
return prop;
}
}
DDL:
Code:
17:40:11,497 INFO Version:15 - Hibernate EntityManager 3.2.1.GA
17:40:11,528 INFO Version:15 - Hibernate Annotations 3.2.1.GA
17:40:11,544 INFO Environment:514 - Hibernate 3.2.4.sp1
17:40:11,544 INFO Environment:547 - hibernate.properties not found
17:40:11,544 INFO Environment:681 - Bytecode provider name : cglib
17:40:11,559 INFO Environment:598 - using JDK 1.4 java.sql.Timestamp handling
17:40:12,169 INFO AnnotationBinder:388 - Binding entity from annotated class: study.persistence.entity.HibValLesson$BaseAbstract
17:40:12,262 INFO EntityBinder:378 - Bind entity study.persistence.entity.HibValLesson$BaseAbstract on table HibValLesson$BaseAbstract
17:40:12,450 INFO AnnotationBinder:388 - Binding entity from annotated class: study.persistence.entity.HibValLesson$Child1
17:40:12,497 INFO AnnotationBinder:388 - Binding entity from annotated class: study.persistence.entity.HibValLesson$Child2
17:40:12,684 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
17:40:12,684 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
17:40:12,684 INFO DriverManagerConnectionProvider:45 - autocommit mode: true
17:40:12,778 INFO DriverManagerConnectionProvider:80 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@172.30.77.173:1521:ORCL
17:40:12,778 INFO DriverManagerConnectionProvider:86 - connection properties: {user=ACOS_ET_NK, password=****, autocommit=true, release_mode=auto}
17:40:14,059 INFO SettingsFactory:89 - RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
17:40:14,059 INFO SettingsFactory:90 - JDBC driver: Oracle JDBC driver, version: 9.2.0.1.0
17:40:14,106 INFO Dialect:152 - Using dialect: org.hibernate.dialect.Oracle10gDialect
17:40:14,122 INFO TransactionFactoryFactory:34 - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
17:40:14,137 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
17:40:14,137 INFO SettingsFactory:143 - Automatic flush during beforeCompletion(): disabled
17:40:14,137 INFO SettingsFactory:147 - Automatic session close at end of transaction: disabled
17:40:14,137 INFO SettingsFactory:154 - JDBC batch size: 15
17:40:14,137 INFO SettingsFactory:157 - JDBC batch updates for versioned data: disabled
17:40:14,137 INFO SettingsFactory:162 - Scrollable result sets: enabled
17:40:14,137 INFO SettingsFactory:170 - JDBC3 getGeneratedKeys(): disabled
17:40:14,137 INFO SettingsFactory:178 - Connection release mode: auto
17:40:14,137 INFO SettingsFactory:205 - Default batch fetch size: 1
17:40:14,137 INFO SettingsFactory:209 - Generate SQL with comments: disabled
17:40:14,137 INFO SettingsFactory:213 - Order SQL updates by primary key: disabled
17:40:14,137 INFO SettingsFactory:217 - Order SQL inserts for batching: disabled
17:40:14,137 INFO SettingsFactory:386 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
17:40:14,153 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
17:40:14,153 INFO SettingsFactory:225 - Query language substitutions: {}
17:40:14,153 INFO SettingsFactory:230 - JPA-QL strict compliance: enabled
17:40:14,153 INFO SettingsFactory:235 - Second-level cache: enabled
17:40:14,153 INFO SettingsFactory:239 - Query cache: disabled
17:40:14,153 INFO SettingsFactory:373 - Cache provider: org.hibernate.cache.NoCacheProvider
17:40:14,153 INFO SettingsFactory:254 - Optimize cache for minimal puts: disabled
17:40:14,153 INFO SettingsFactory:263 - Structured second-level cache entries: disabled
17:40:14,200 INFO SettingsFactory:283 - Echoing all SQL to stdout
17:40:14,200 INFO SettingsFactory:290 - Statistics: disabled
17:40:14,200 INFO SettingsFactory:294 - Deleted entity synthetic identifier rollback: disabled
17:40:14,200 INFO SettingsFactory:309 - Default entity-mode: pojo
17:40:14,200 INFO SettingsFactory:313 - Named query checking : enabled
17:40:14,341 INFO SessionFactoryImpl:161 - building session factory
17:40:14,966 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
17:40:15,012 INFO SchemaExport:154 - Running hbm2ddl schema export
17:40:15,012 DEBUG SchemaExport:170 - import file not found: /import.sql
17:40:15,012 INFO SchemaExport:179 - exporting generated schema to database
17:40:15,012 DEBUG SchemaExport:303 - drop table HibValLesson$BaseAbstract cascade constraints
17:40:17,309 DEBUG SchemaExport:303 - drop sequence hibernate_sequence
17:40:17,700 DEBUG SchemaExport:303 - create table HibValLesson$BaseAbstract (DTYPE varchar2(31 char) not null, id number(19,0) not null, name varchar2(255 char), prop number(10,0) check (prop>=6 and prop<=10), primary key (id))
17:40:18,122 DEBUG SchemaExport:303 - create sequence hibernate_sequence
17:40:18,169 INFO SchemaExport:196 - schema export complete
As you can see - there is a constraint
Quote:
check (prop>=6 and prop<=10)
.