2014-12-18 6 views
1

최대 절전 모드 도구는 javacode에서 부울 유형에 tinyint(1)을 생성합니다. 기본값 : 0 false, 1 trueHibernate + MySQL 사용자 정의 부울 유형

하지만 1 : false 및 0 : true로 변경하려고합니다.

어떻게 할 수 있습니까?

내 datasource.xml에 <prop key="hibernate.query.substitutions">true 0, false 1</prop>을 추가했지만 여전히 작동하지 않습니다.

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> 
    <!-- Read database connection from data source --> 
    <property name="dataSource"> 
     <ref bean="dataSource" /> 
    </property> 
    <!-- Config hibernate properties --> 
    <property name="hibernateProperties"> 
     <props> 
      <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop> 
      <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> 
      <prop key="hibernate.format_sql">true</prop> 
      <!-- Minimum number of JDBC connections in the pool. Hibernate default: 1 --> 
      <prop key="hibernate.c3p0.min_size">5</prop> 
      <!-- Maximum number of JDBC connections in the pool. Hibernate default: 100 --> 
      <prop key="hibernate.c3p0.max_size">20</prop> 
      <!-- When an idle connection is removed from the pool (in second). Hibernate default: 0, never expire. --> 
      <prop key="hibernate.c3p0.timeout">300</prop> 
      <!-- Number of prepared statements will be cached. Increase performance. Hibernate default: 0 , caching is disable. --> 
      <prop key="hibernate.c3p0.max_statements">50</prop> 
      <!-- Hibernate.c3p0.idle_test_period – idle time in seconds before a connection is automatically validated. Hibernate default: 0 --> 
      <prop key="hibernate.c3p0.idle_test_period">3000</prop> 
      <prop key="hibernate.query.substitutions">true 0, false 1</prop> 
     </props> 
    </property> 

도와주세요. 고맙습니다.

+0

참조 : http : //stackoverflow.com/questions/1154833/configure-hibernate-using-jpa-to-store-yn-for-type-boolean-instead-of-0-1 – user23123412

+0

당신 –

답변

0
아래로 속성을 변경하고 확인

<property name="hibernate.query.substitutions" value="true 0, false 1" /> 

정보와 같은 몇 가지 일을 볼 수있는 정보 수준 로그에서 또한

@Column(name = “is_active”, columnDefinition=”TINYINT(1)”) 
private boolean isActive; 

같은 코드는해야한다 SettingsFactory : 203 - 검색어 대체 : {true = 0, false = 1}

이전 버전의 최대 절전 모드 (https://hibernate.atlassian.net/browse/HHH-165)에서는 query.substitutions에 몇 가지 문제가있는 것으로 보이지만 최신 버전에서도 동일하게 확인하십시오.