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 4533078
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:06:36+00:00 2026-05-21T14:06:36+00:00

I am storing an Object into my database, and I think I am making

  • 0

I am storing an Object into my database, and I think I am making some stupid mistake which I don’t see. I attached some code to understand my problem:

MyObject.java object which I want to store in the database

@Entity
@Table(name = "my_object")
public class MyObject {
    private String idName;
    
    @Id
    @Column(name = "id", unique = true, length = 50,nullable=false)
    public String getIdName() {
        return idName;
    }
    public void setIdName(String idName) {
        this.idName = idName;
        this.id = idName.hashCode();
    }

TestToStoreObject.java

    MyObject obj = new MyObject();
                
                obj.setIdName("id");
//More set ...
                save(obj);

Function to store the Object into the database

protected void save(MyObject obj) throws DataAccessLayerException {
        try{
            getHibernateTemplate().save(obj);
        } catch (HibernateException e) {
            handleException(e);
        }
    }

This is a general function which is working with other datatypes. So where I guess the problem is, is in configuration files. The exception is:

org.springframework.dao.InvalidDataAccessResourceUsageException:
   could not insert: [path.MyObject]; SQL [insert into object (id) values (?)];
nested exception is org.hibernate.exception.SQLGrammarException: 
   could not insert: [path.MyObject]

Here more configuration files:
HibernatePlatform.cfg.xml

 <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC
            "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
            "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
        <session-factory>
            <mapping class="path.User" />
            <mapping class="path.MyObject" />
  • 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-05-21T14:06:36+00:00Added an answer on May 21, 2026 at 2:06 pm

    The problem was that I had another class with the same name in another package, and it was messing. A piece of advise for the future: chach this small things!!

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

Sidebar

Related Questions

I need to create a data transfer object, which I will use for storing
I'm just playing with attributes, which contains some info about a specific database field.
I put together some VBA code for Outlook 2007 which has been working predominantly
I have an xml document object that I need to convert into a string.
I need to serialize/de-serialize some objects into/from string and transfer them as just opaque
I'm storing an object ( TTF_Font ) in a shared_ptr that is provided to
How can I go about storing a vb.net user defined object in a sql
I have to work with some code that isn't truly MVC (i.e., it doesn't
I'm very new to django, about a week into it. I'm making a site
I need to insert a python tuple (of floats) into a MySQL database. In

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.