• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Issue in inserting into DB using Hibernate, Spring

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am setting up the enviornment for my project in Sturts with Spring and Hibernate and facing the below issue.
First, I am trying to add the bank details in the DB as below.
The flow executed properly, but when querying the table no records found.
For example:
I have added the bank details with bank code 4000 (primary) and it's executed and I can able to see the insert query in the console, but record is not inserted into DB.
But when I tried to insert the bank code again with 4000, I am getting duplication error.

I have give below the codings. Please help to advice.











 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you find anything?

Because the bindings seems to be right

Can you try with some other DB.(Might be your database is corrupted.)
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Thomson wrote:
I have added the bank details with bank code 4000 (primary) and it's executed and I can able to see the insert query in the console, but record is not inserted into DB.
But when I tried to insert the bank code again with 4000, I am getting duplication error.



BankCode or BankId???

According to your comment bank code is the primary. According to the XML mapping BankId is your Id, bank code is just unique. Do you have other records in the database with bank code 4000??

Look into your table status and check the autoIncrement value. If something is being inserted that should update.

Another question. Why is the error code saying "could not insert: [com.mdd.web.pojo.Bank] " and your XML says:

<class catalog="mysql" name="com.mdd.web.persistance.bank.Bank" table="bank">

Seems like the xml you published does not correspond to the class that is generating the error when being inserted.
 
Mike Thomson
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


BankCode or BankId???

According to your comment bank code is the primary. According to the XML mapping BankId is your Id, bank code is just unique. Do you have other records in the database with bank code 4000??

Look into your table status and check the autoIncrement value. If something is being inserted that should update.

Another question. Why is the error code saying "could not insert: [com.mdd.web.pojo.Bank] " and your XML says:

<class catalog="mysql" name="com.mdd.web.persistance.bank.Bank" table="bank">

Seems like the xml you published does not correspond to the class that is generating the error when being inserted.




1. Yes, Bank Id is primary and bank code is unique.
2. The table mysql.bank is empty. No record is there.
3. I have given the wrong class name, it should be com.mdd.web.pojo.Bank in Bank.hbm.xml file



I am not getting any errors/exception and I can able to see the insert query into the console, but the record is not in the table.However strangely If I try to give the same bank code, then duplication error, but records in that bank table. How come this error? Please help on this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic