IDENTITY columns and Java Objects

  • I want to use IDENTITY columns in my database. Java devs are telling me that this creates problems for them because of object-relational mapping problems. They need to be able to put objects into collections before persisting them to the database, which means they need an ID outside the database.
    Does anyone know of solutions to this problem that'll allow me to still use IDENTITY columns?
    I'm trying to figure out the best way to google for this and writing out the question helps.

    --------------------------------------
    When you encounter a problem, if the solution isn't readily evident go back to the start and check your assumptions.
    --------------------------------------
    It’s unpleasantly like being drunk.
    What’s so unpleasant about being drunk?
    You ask a glass of water. -- Douglas Adams

  • Just because there's an identity column in the database doesn't mean they have to use it in their data model.  If they want to use an external system to keep track of ID's for whatever reason let them, if you're worried about integrity on that column make it a NOT NULL column and put a unique index on it, or for that matter make their key column the primary key an identity doesn't have to be the primary key.  

    Regardless there's no reason you can't have an identity column at the database level.

  • Sioban Krzywicki - Tuesday, March 27, 2018 8:14 AM

    I want to use IDENTITY columns in my database. Java devs are telling me that this creates problems for them because of object-relational mapping problems. They need to be able to put objects into collections before persisting them to the database, which means they need an ID outside the database.
    Does anyone know of solutions to this problem that'll allow me to still use IDENTITY columns?
    I'm trying to figure out the best way to google for this and writing out the question helps.

    Why are the Java devs creating the database objects?   That's a DBA role, and separation of duties suggests strongly that using Java to do that at all is probably a bad idea.

    Steve (aka sgmunson) πŸ™‚ πŸ™‚ πŸ™‚
    Rent Servers for Income (picks and shovels strategy)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply