-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Guys, please, help with bug in Hibernate Validator
PostPosted: Wed Aug 06, 2008 6:34 am 
Newbie

Joined: Fri Aug 01, 2008 6:29 am
Posts: 4
I have faced with strange behavior of Hibernate Validator.
I want to disable DDL generation for my classes. But cannot enforce Hibernate Validator Framework to do so.

As described in Reference Guide(3.0.0.GA), I set hibernate.validator.apply_to_ddl to false in persistence.xml

Code:
<property name="hibernate.validator.apply_to_ddl" value="false"/>



But it doesn't help.
I'm still receiving constraints on my DB.

Maybe I'm doing something wrong? Who can help?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 07, 2008 9:20 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Can you post the version numbers of the libraries you use, your mapping and the DDL generated?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 07, 2008 10:58 am 
Newbie

Joined: Fri Aug 01, 2008 6:29 am
Posts: 4
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)
.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 07, 2008 11:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't remember if Annotation 3.2.1 has this feature (Annotations is really the one applying the DDL changes), but for sure Annotations 3.3 has it (I have a unit test to check that the DDL is not altered).

Can you give it another try with Annotations 3.3 explicitly?

_________________
Emmanuel


Top
 Profile  
 
 Post subject: I am having the same problem.
PostPosted: Tue Aug 12, 2008 4:53 pm 
Regular
Regular

Joined: Wed Nov 17, 2004 11:49 am
Posts: 65
Location: Pittsburgh
Any luck with the newer version of annotations? I am having the same issue. Also, I would note that I wouldn't mind having the DDL changes, except that the @Past annotation is generating invalid [Oracle 10g XPress] DDL for the check constraint:

Code:
     [exec] 16:46:11,875 INFO  [SchemaExport] Running hbm2ddl schema export
     [exec] 16:46:11,875 INFO  [SchemaExport] exporting generated schema to data
base
     [exec] 16:46:12,046 ERROR [SchemaExport] Unsuccessful: create table MockEnt
ity (id number(19,0) not null, mockInt number(10,0) not null check (mockInt>=5 a
nd mockInt<=10), mockString varchar2(255 char) not null, mockBigDecimal number(1
6,5), mockDate timestamp check (mockDate < current_date), PARENT_ID number(19,0)
, primary key (id))
     [exec] 16:46:12,046 ERROR [SchemaExport] ORA-02436: date or system variable
wrongly specified in CHECK constraint
     [exec]


Code:
@Entity
public class MockEntity extends BaseEntity {
   @Id
   private Long id;
   
   @Range(min=5, max=10)
   private int mockInt;
   
   @NotEmpty
   private String mockString;
   
   @Column(precision=16, scale=5)
   private BigDecimal mockBigDecimal;
   
   @Past
   private Date mockDate;

...



Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 14, 2008 3:48 am 
Newbie

Joined: Fri Aug 01, 2008 6:29 am
Posts: 4
You are right, no success with newer versions.
My reasons to avoid DDL generation also came from inappropriate HibValidator behavior.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 14, 2008 2:39 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I have disabled @Past check generation in HV 3.1.0 (SVN). ANSI disallows this function in check, I guess because you *could* use it wrong.
HV-65

Note if you can post a minimal reproducible case where the ddl is still generated despite the property on the latest version, create a JIRA issue too. I haven't been able to reproduce.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.