Please Enable JavaScript!
Gon[ Enable JavaScript ]

Hibernate 입력관련 에러

자바(JAVA)
반응형
CRUD 구현을 위한 첫걸음으로 저장을 하는 과정에서 나는 에러들이다.

readOnly marker 에러인데 트랜잭션을 위해서 hibernate 연결 설정을 한 xml 파일이있다.
그내용이 아래와 같은데 Template 에서 save 함수 호출전 함수명이 insert*, update*, delete*
이외의 함수명이 오면 실행을 할수가 없다.

org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

<bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
     <property name="transactionManager" ref="transactionHibernateManager"/>
     <property name="transactionAttributes">
      <props>
       <prop key="insert*">PROPAGATION_REQUIRED</prop>
       <prop key="update*">PROPAGATION_REQUIRED</prop>
       <prop key="delete*">PROPAGATION_REQUIRED</prop>
       <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
      </props>
     </property>
</bean>


이 에러는 hbm.xml  맵핑파일과 DB Table 의 속성값이 일치 하지 않아서 나는 에러이다. xml 설정에서는
자동증가해서 넣을려고 하는데 DB Table 에 no 속성을 identity 증가를 설정해 놓았다.
xml 에 increment 없애던지 아니면 Table no 속성에서 identity 증가를 없애면 된다.

org.springframework.orm.hibernate3.HibernateSystemException: ids for this class must be manually assigned before calling save(): gon.front.board.model.TbBoard; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): gon.front.board.model.TbBoard

<id  name="Id"  type="integer"  column="no">
   <generator class="increment"/>
</id>

이 에러도 위와 마찬가지의 경우에 발생한다.

 Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Cannot insert explicit value for identity column in table 't_artikel' when IDENTITY_INSERT is set to OFF.

다음은 xml 에 not-null="true" 값을 설정하고 아무 값을 안넣었을때 발생한다.
이 not-null 속성의 설정은 DB Table column 속성과 같아야 할것이다.

Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: gon.front.board.model.TbBoard.Idate

<property  name="Uid"  column="uid"  type="string" not-null="true" length="50" />


반응형
Posted by 녹두장군1
,