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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:10:57+00:00 2026-06-08T18:10:57+00:00

I am using mysql and hibernate to insert and update rows in a table.

  • 0

I am using mysql and hibernate to insert and update rows in a table. I use saveOrUpdate call. Now, When I try to update a row in a table, I get a exception. Exception states that my column requestTime cannot be null. Obviously its true since I have setup the column property to be NotNull.

I am able to add the row. But when update it with values of 2 more columns, I get this exception.

I am assuming that when I update, I need to read the row from the table, and update the entire row. Is that true ? I was kinda hoping that hibernate saveOrUpdate would do it for me. So I have a Object that has getters for all the columns when I insert a new row. But when I update I have a Object that only has getters for the primary key and new columns.

Transaction txD;
Session session;
session = currentSession();
txD = session.beginTransaction();
session.saveOrUpdate(dataStore);
txD.commit();

Exception

749368 [Thread-2] DEBUG org.hibernate.internal.util.EntityPrinter  - com.mcruiseon.carpool.concrete.SubscribeProviderConcrete{acceptedTime=Mon Jul 30 03:39:23 UTC 2012, requestTime=null, subscriberIdentityHash=1218553253, requestIdentity=167093126, subscribedProviderHash=-284086361, isAccepted=true}
749375 [Thread-2] DEBUG org.hibernate.SQL  - update carPoolSubscribedProvider set subscriberIdentityHash=?, requestTime=?, subscribedProviderHash=?, isAccepted=?, acceptedTime=? where requestIdentity=?
749398 [Thread-2] DEBUG org.hibernate.engine.jdbc.spi.SqlExceptionHelper  - Column 'requestTime' cannot be null [n/a]
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'requestTime' cannot be null

select * from carPoolSubscribedProvider

+-----------------+------------------------+---------------------+------------------------+------------+--------------+
| requestIdentity | subscriberIdentityHash | requestTime         | subscribedProviderHash | isAccepted | acceptedTime |
+-----------------+------------------------+---------------------+------------------------+------------+--------------+
| 167093126       | -284086361             | 2012-07-27 16:13:19 | 1218553253             |          0 | NULL         |
+-----------------+------------------------+---------------------+------------------------+------------+--------------+

Edit :

| carPoolSubscribedProvider | CREATE TABLE `carPoolSubscribedProvider` (
  `requestIdentity` varchar(50) NOT NULL DEFAULT '',
  `subscriberIdentityHash` varchar(100) NOT NULL,
  `requestTime` datetime NOT NULL,
  `subscribedProviderHash` varchar(100) DEFAULT NULL,
  `isAccepted` tinyint(1) DEFAULT '0',
  `acceptedTime` datetime DEFAULT NULL,
  PRIMARY KEY (`requestIdentity`),
  • 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-08T18:11:00+00:00Added an answer on June 8, 2026 at 6:11 pm

    Hibernate cannot figure out how you want attribute with null value be treted. It cannot make difference between cases where:

    1. some attribute is null -> should set to null in database
    2. some attribute is null -> should not update such an attribute.

    Setting value for attribute that was previously non-null to null means that value of attribute should be changed.

    If you want to make column never be part of update statement, you can set updatable attribute to false in @Column annotation. According documentation it defines: Whether the column is included in SQL UPDATE statements generated by the persistence provider

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

Sidebar

Related Questions

I have made an application using Java/Hibernate/MySQL, but whenever I try running it, it
i am not able to insert a record. i am using hibernate and mysql.
I'm having trouble getting Hibernate to perform a bulk insert on MySQL. I'm using
I am using GWT RPC & Hibernate to insert and retrieve data from MySql
I am using GWT RPC & Hibernate to insert and retrieve data from MySQL
I am using hibernate. When I try to insert values into my db I
I am using java-hibernate-mysql combination When i m doing update query i m getting
I'm using: Hibernate MySQL jBoss I have to create an application that allows user
I'm writing a webapp, and interfacing with MySQL using Hibernate 3.5. Using デスクトップ ინგლისური
I have a webservice using Hibernate as DAL - using MySql with InnoDB. Since

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.