axboot / ax-boot-framework

Full Stack Java Web Application Framework with Java & HTML5
http://www.axboot.com
MIT License
242 stars 70 forks source link

h2에서 oracle 로 db변경시 오류 #14

Closed jsw418jj closed 8 years ago

jsw418jj commented 8 years ago

oracle로 db를 변경하는 작업을 하고 있습니다.

oracle xe 버젼에서 테이블을 생성하고 테스트 데이터는 입력했습니다. 시퀀스도 추가했습니다.

axboot-local.properties

axboot.dataSource.username=*****
axboot.dataSource.password=*****
axboot.dataSource.url=jdbc:oracle:thin:@localhost:1521:xe
axboot.dataSource.driverClassName=oracle.jdbc.driver.OracleDriver
axboot.dataSource.initialSize=5
axboot.dataSource.maxIdle=-1
axboot.dataSource.maxTotal=10
axboot.dataSource.maxWaitMillis=3000
axboot.dataSource.slowQueryThreshold=3000
axboot.dataSource.hibernate.hbm2ddlAuto=none
axboot.dataSource.hibernate.databaseType=oracle

Menu.java

@Setter
@Getter
@DynamicInsert
@DynamicUpdate 
@Entity
@EqualsAndHashCode(callSuper = true) 
@Table(name = "MENU_M")
@Comment(value = "메뉴")   
@ToString
public class Menu extends BaseJpaModel<Long> implements Cloneable {

    @Id
    @Column(name = "MENU_ID", precision = 20, nullable = false)
    @Comment(value = "ID")
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="SEQ_MENU_M")
    @SequenceGenerator( 
            name="SEQ_MENU_M", 
            sequenceName="SEQ_MENU_M",
            allocationSize = 1,
            initialValue = 11
        )
    @ColumnPosition(1)  
    private Long menuId;

테이블 명도 @table 어노테이션에 설정을 다했고 @GeneratedValue 는 sequence로 변경을 해서 소스마다 수정 했습니다.

이렇게 해서 빌드를 하니

2016-11-02 13:15:58 [http-nio-7777-exec-1] DEBUG org.springframework.jdbc.datasource.DataSourceUtils:resetConnectionAfterTransaction:222 Resetting read-only flag of JDBC Connection [471872047, URL=jdbc:oracle:thin:@localhost:1521:xe, UserName=****, Oracle JDBC driver]
2016-11-02 13:15:58 [http-nio-7777-exec-1] ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[jsp]:log:181 Servlet.service() for servlet [jsp] in context with path [] threw exception
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:261)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:491)
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy163.findOne(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.zeroturnaround.javarebel.integration.util.ReloadingProxyFactory$ReloadingMethodHandler.invoke(JRebel:74)
    at com.sun.proxy.$Proxy163.findOne(Unknown Source)
    at com.chequer.axboot.core.domain.base.AXBootBaseService.findOne(AXBootBaseService.java:158)
    at com.chequer.axboot.core.domain.base.AXBootBaseService$$FastClassBySpringCGLIB$$8e61d94.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:651)
    at com.gaubiz.domain.program.menu.MenuService$$EnhancerBySpringCGLIB$$fc4faf58.findOne(<generated>)
    at com.gaubiz.security.AXBootTokenAuthenticationService.getAuthentication(AXBootTokenAuthenticationService.java:85)
    at com.gaubiz.security.AXBootAuthenticationFilter.doFilter(AXBootAuthenticationFilter.java:32)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:121)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at com.chequer.axboot.core.filters.MultiReadableHttpServletRequestFilter.doFilter(MultiReadableHttpServletRequestFilter.java:15)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:108)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

이런 오류가 발생하였습니다.

오라클 연동을 하려면 어떻게 해야 하나요??

jsw418jj commented 8 years ago

자답입니다.

원인은 MENU.java와 MANUAL.java의 컬럼중 LEVEL 이라는 컬럼이 oracle 예약어로 사용되기 때문에 발생하였습니다.

DB상에서 LEVEL이라는 컬럼명을 변경하고 java에 셋팅을 해주면 해결됩니다.