Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Cannot insert null into a non nullable column  RSS feed

Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
Am new to JPA / Hibernate / ORM

Facing a strange issue .

1 >Created a simple table in HSQLDB
2 >Then using JPA tried persisting the data - and it worked fine

Here in DB had not defined the primary key explicitly

Now I tried to use the "Embedded" attribute
( Single Table - but two Java objects )

The problem that I am facing is that if I use :

it works fine

For other options ( AUTO , IDENTITY ) get the exception ::
Caused by: java.sql.SQLException: Attempt to insert null into a non-nullable column: column: CUST_ID

Can anyone provide some pointers related to ::
1 >
when I dont use @embedded & @Embeddable I can simply do an insert using GenerationType.AUTO - This works

2 >
when I use @embedded & @Embeddable I CANNOT do an insert unless I use

Thanks ,
Posts: 17344
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I might just be confused, but embedded objects won't have an @Id on it, since it is a dependant object on another object, and that object will have the pk.

Embedded is a case where, for example, you have this table, and you want two seperate objects in Java to represent all the stuff in that one table.


Table User


And you want a User and an Address object to represent all the fields in that User table.

Address object doesn't have the id, it is in the User object. So Address is an Embedded object for the User object.

Hope that helps clear some things up if I am correctly understanding what you are asking.

Look ma! I'm selling my stuff!
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!