generate DB record id in the DB and not in java
hey guys. i have pojo that is being inserted into my DB. i dont want to have
id
field in my pojo and let my DB generate record id. can i do it somehow? thanks7 Replies
⌛
This post has been reserved for your question.
Hey @bambyzas! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Is your Pojo an Entity?
What is your database vendor? Postgres, Oracle, Mysql?
My questions would be what counts as the DB and what counts as Java.
As far as the DB is concerned, objects don't exist. you call INSERT statements to it. That's it.
Admittedly some while allow to create columns where an id is automatically created when inserting a row in their table, but that doesn't sound much like what's asked.
@Kyo-chan Depends, Postgres usually use a sequence to notify the next free number. Oracle 12c can use the new built-in column type identity (https://oracle-base.com/articles/12c/identity-columns-in-oracle-12cr1) what is the most clean solution. The primary-key annotation must differ depending on the database implementation!
......... That doesn't address what I was saying
Yes, sorry, you are right.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.