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

Is there any reason why storing a NSData object of say ~50MB into NSUserDefaults
I wanted to get some feedback on your thoughts of storing entire objects into
I am trying to move an object from one database into another. The mappings
I'm just playing with attributes, which contains some info about a specific database field.
I want to convert an OutputStream into a String object. I am having an
initWithData does not convert my data object into a string properly. When I check
Is it possible to serialize an object into a string or a byte array
How does one turn any random object into a JSON string using Monodroid's System.Json
I try to change a string into an object using eval but failed. var
I'm parsing a XML string into XMLDocument object. I want to search for a

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.