Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9060287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:11:21+00:00 2026-06-16T15:11:21+00:00

I am working on website for classified ads using spring 3.1 and hibernate 3.6

  • 0

I am working on website for classified ads using spring 3.1 and hibernate 3.6. I have four entities (User, UserRole, Advertisement and Category). I am using a separate dao for each class. All the operations in Daos for User and UserRoles work fine. But in the daos for Advertisement and Category, save/update throws an SQLGrammarException.

Advertisement Class

    @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
    }

Category Class

    @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
    }

AdvertisementDao

    @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;
        }

    }

Table

        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;

Calling the save method

            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);

This is the error

            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

I tried removing the ManytoOne associations (removing USER_ID and CAT_ID FKs), but I cannot save to these two tables. But I can get an object of Advertisement class by calling advertisementDao.getAdById(id), it also loads relevent Category object and User object automatically. I have also added all the four classes to hibernate config file.

I can’t see what gives this error. Finally I tried to create a SQL Insert query in the traditional way by getting Query object from session. It also give this same error. Please help me. Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:11:23+00:00Added an answer on June 16, 2026 at 3:11 pm

    DESC is a reserved word in MySQL, so you can’t use it for a column name. You should rename you column for the insertion to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a website that has Employee and Branch entities, using a database table
I'm working on a classified listing style website and I'm pretty new to Rails...
I have a working website, where I use this expression everywhere. price.ToString(C) It currently
I have working website in PHP with a MySQL backend which has several tables
I have a classifieds website, and when users post a new classified, they may
So I already have the website working (I'm not working from scratch). The problem
I am working on classified site. I am using PHP and MySql for that.
I'm trying to add a payment method to working website that is using a
I am working on website on which under the root, i have under construction
I am working on website using ajax and C#. I started learning these languages

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.