1

spring 3.1hibernate 3.6を使用して、案内広告の Web サイトに取り組んでいます。4 つのエンティティ ( UserUserRoleAdvertisementおよびCategory) があります。クラスごとに個別のdaoを使用しています。Daos forUserおよびfor のすべての操作は正常にUserRoles機能します。Advertisementしかし、およびのdaosCategoryでは、保存/更新はSQLGrammarException.

広告クラス

    @Entity
    @Table(name="ads")
    public class Advertisement implements Serializable {

        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue
        @Column(name = "AD_ID")
        private String adId;

        @ManyToOne(cascade = CascadeType.ALL)
        @JoinColumn(name="CAT_ID" )
        private Category category;

        @ManyToOne(cascade = CascadeType.ALL)
        @JoinColumn(name="USER_ID" )
        private User user;


        @Column(name = "TITLE")
        private String title;

        @Column(name = "DESC", nullable = true)
        private String desc;

        @Column(name = "PRICE")
        private double price;

        @Column(name ="IMG1" , nullable = true)
        private String imageOne;

        @Column(name ="IMG2" , nullable = true)
        private String imageTwo;

        @Column(name ="IMG3" , nullable = true)
        private String imageThree;

        @Temporal(TemporalType.TIMESTAMP)
        @Column(name ="CREATED")
        private Date createdOn;

        //Getters and setters
    }

カテゴリ クラス

    @Entity
    @Table(name="cats")
    public class Category implements Serializable {

        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue
        @Column(name = "CAT_ID")
        private String catId;

        @Column(name = "CAT_NAME", unique=true)
        private String catName;

        @Column(name ="DESC" , nullable = true)
        private String desc;

        @OneToMany(mappedBy="category", fetch=FetchType.LAZY)
        private List<Advertisement> allAds;

        //getters and setters
    }

広告ダオ

    @Repository
    @Transactional
    public class AdvertisementDaoImpl implements AdvertisementDao {

        private HibernateTemplate hibernateTemplate;

        @Autowired
        public void setSessionFactory(SessionFactory sessionFactory) 
        {
            this.hibernateTemplate = new HibernateTemplate(sessionFactory);
        }

        @Override
        public void save(Advertisement ad) 
        {       
            hibernateTemplate.save(ad);

        }

        @Override
        public void update(Advertisement ad) {
            hibernateTemplate.update(ad);

        }

        @Override
        public void delete(Advertisement ad) {
          hibernateTemplate.delete(ad);

        }

        @Override
        public Advertisement getAdById(String adId) {

            Advertisement ad = (Advertisement) hibernateTemplate.get(Advertisement.class, adId);

            return ad;
        }

        @SuppressWarnings("unchecked")
        @Override
        public List<Advertisement> getAdsByUserId(String userId) {

            String sql = "SELECT * FROM ads USER_ID = :uID";

            List <Advertisement> adList= new ArrayList<Advertisement>();

            Query qry = hibernateTemplate.getSessionFactory().getCurrentSession().
                        createSQLQuery(sql)
                        .addEntity(Advertisement.class)
                        .setParameter("uID", userId);

            adList = ( List <Advertisement> ) qry.list();

            return adList;
        }

    }

テーブル

        CREATE TABLE IF NOT EXISTS `ads` (
          `AD_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
          `CAT_ID` int(10) unsigned NOT NULL,
          `USER_ID` int(10) unsigned NOT NULL,
          `TITLE` varchar(200) NOT NULL,
          `PRICE` double unsigned NOT NULL,
          `DESC` varchar(2000) DEFAULT NULL,
          `IMG1` varchar(400) DEFAULT NULL,
          `IMG2` varchar(400) DEFAULT NULL,
          `IMG3` varchar(400) DEFAULT NULL,
          `CREATED` timestamp NOT NULL,
          PRIMARY KEY (`AD_ID`),
          KEY `CAT_ID` (`CAT_ID`),
          KEY `USER_ID` (`USER_ID`)
        ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
        ALTER TABLE `ads`
          ADD CONSTRAINT `ads_ibfk_2` FOREIGN KEY (`USER_ID`) REFERENCES `users` (`USER_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
          ADD CONSTRAINT `ads_ibfk_1` FOREIGN KEY (`CAT_ID`) REFERENCES `categories` (`CAT_ID`) ON DELETE CASCADE ON UPDATE CASCADE;

保存メソッドの呼び出し

            Advertisement ad2= new Advertisement();

            ad2.setCategory(categoryDao.getAllCategories().get(2));

            ad2.setUser(UserService.getCurrentUser());
            ad2.setImageOne(null);
            ad2.setImageTwo(null);
            ad2.setImageThree(null);

            ad2.setCreatedOn(new Date());

            ad2.setPrice(102.0);

            ad2.setTitle("New ad");

            ad2.setDesc("descriptions");
            advertisementDao.save(ad2);

これがエラーです

            HTTP Status 500 - Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert: [com.slclassifieds.adsonline.model.Advertisement]; SQL [insert into ads (CAT_ID, CREATED, DESC, IMG1, IMG3, IMG2, PRICE, TITLE, USER_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not insert: [com.slclassifieds.adsonline.model.Advertisement]

            type Exception report

            message Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert: [com.slclassifieds.adsonline.model.Advertisement]; SQL [insert into ads (CAT_ID, CREATED, DESC, IMG1, IMG3, IMG2, PRICE, TITLE, USER_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not insert: [com.slclassifieds.adsonline.model.Advertisement]

            description The server encountered an internal error that prevented it from fulfilling this request.

            exception

            org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert: [com.slclassifieds.adsonline.model.Advertisement]; SQL [insert into ads (CAT_ID, CREATED, DESC, IMG1, IMG3, IMG2, PRICE, TITLE, USER_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not insert: [com.slclassifieds.adsonline.model.Advertisement]
                org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
                org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
                javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
                javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
                org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
                org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
                org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
                org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
                org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
            root cause

            org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert: [com.slclassifieds.adsonline.model.Advertisement]; SQL [insert into ads (CAT_ID, CREATED, DESC, IMG1, IMG3, IMG2, PRICE, TITLE, USER_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not insert: [com.slclassifieds.adsonline.model.Advertisement]
                org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:635)
                org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
                org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
                org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
                org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:737)
                com.slclassifieds.adsonline.dao.AdvertisementDaoImpl.save(AdvertisementDaoImpl.java:32)
                sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                java.lang.reflect.Method.invoke(Method.java:601)
                org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
                org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
                org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
                org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
                org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
                $Proxy27.save(Unknown Source)
                com.slclassifieds.adsonline.web.AdController.viewAdDetails(AdController.java:66)
                sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                java.lang.reflect.Method.invoke(Method.java:601)
                org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
                org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
                org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
                org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
                org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
                org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
                org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
                org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
                org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
                org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
                javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
                javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
                org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
                org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
                org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
                org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
                org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
            root cause

            org.hibernate.exception.SQLGrammarException: could not insert: [com.slclassifieds.adsonline.model.Advertisement]
                org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
                org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
                org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:63)
                org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2346)
                org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2853)
                org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
                org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
                org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:320)
                org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203)
                org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:129)
                org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
                org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
                org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
                org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
                org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:685)
                org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:677)
                org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:673)
                org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:740)
                org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
                org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
                org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:737)
                com.slclassifieds.adsonline.dao.AdvertisementDaoImpl.save(AdvertisementDaoImpl.java:32)
                sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                java.lang.reflect.Method.invoke(Method.java:601)
                org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
                org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
                org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
                org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
                org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
                $Proxy27.save(Unknown Source)
                com.slclassifieds.adsonline.web.AdController.viewAdDetails(AdController.java:66)
                sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                java.lang.reflect.Method.invoke(Method.java:601)
                org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
                org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
                org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
                org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
                org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
                org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
                org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
                org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
                org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
                org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
                javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
                javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
                org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
                org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
                org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
                org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
                org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
                org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
                org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
            root cause

            com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC, IMG1, IMG3, IMG2, PRICE, TITLE, USER_ID) values ('3', '2013-01-01 19:09:30' at line 1

ManytoOne 関連付けを削除しようとしましたが (USER_ID および CAT_ID FK を削除)、これら 2 つのテーブルに保存できません。しかし、 Advertisement クラスのオブジェクトは を呼び出すことで取得でき、advertisementDao.getAdById(id)関連する Category オブジェクトと User オブジェクトも自動的に読み込まれます。また、4 つのクラスすべてを hibernate 構成ファイルに追加しました。

このエラーの原因がわかりません。最後に、セッションから Query オブジェクトを取得して、従来の方法で SQL Insert クエリを作成しようとしました。また、これと同じエラーが発生します。私を助けてください。ありがとうございました

4

1 に答える 1