facebook

problem with primary key and hibernate and oracle

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #312577 Reply

    JamesRaynor
    Member

    hi

    i am doing a three table database: state, county, and city.
    state table only has a st_key and name,
    county table has cnt_key, name and st_key as FK.
    and the city table has a key, ct_key, cnt_key, st_key and name

    right now i am only doing some testing on how to use hibernate and i am creating my classes for that. the problem is when i try to insert.

    hibernate created for me the abstractState, state and stateDAO,
    so i do what the tutorials say i must do:
    create my state
    set it
    put it in a dao
    and commit it

    but when i check my table in oracle i see that the key that i set is not what set it to
    the update and delete seem to work for the values already there.

    and something curious, when i tries to see all of my methods for the state there was no setId. is there a problem with that?

    #312586 Reply

    JamesRaynor,

    I am unable to replicate it at my end.

    Do you see any errors specific to hibernate in the log file? You can find it at <workspacedir>/.metadata folder.

    Here are the links which can help you with creating Hibernate projects.

    http://www.myeclipseide.com/documentation/quickstarts/hibernate/
    http://www.myeclipseide.com/documentation/quickstarts/hibernateintroduction/

    Please go through them and try creating a new Project.

    Do let us know how it works for you.

    #312598 Reply

    JamesRaynor
    Member

    thank you shalini,

    but i was using those tutorials, i have redone everything(thats java) and get the same result.

    one thing that i get is that when i retry to save a dao that already exists instead of not doing anything and keeping the database as is, it generates a new entry.

    for example if i enter in the state table:
    st_key = 1, name = abc
    and then do it again
    i get a table like:

    st_key | name
    1 | abc
    11 | abc
    12 | abc
    13 | abc
    and so on

    and i get that even if i change the key…
    is there something like an auto generate key on hibernate? or maybe its oracle?
    but i didn’t set my tables like that, but if so where can i check if i did?

    i am a complete noob on oracle, but i find it very useful. any web page or tutorial that you recommend????

    #312599 Reply

    JamesRaynor
    Member

    thank you shalini,

    but i was using those tutorials, i have redone everything(thats java) and get the same result.

    one thing that i get is that when i retry to save a dao that already exists instead of not doing anything and keeping the database as is, it generates a new entry.

    for example if i enter in the state table:
    st_key = 1, name = abc
    and then do it again
    i get a table like:

    st_key | name
    1 | abc
    11 | abc
    12 | abc
    13 | abc
    and so on

    and i get that even if i change the key…
    is there something like an auto generate key on hibernate? or maybe its oracle?
    but i didn’t set my tables like that, but if so where can i check if i did?

    i am a complete noob on oracle, but i find it very useful. any web page or tutorial that you recommend????

    #312600 Reply

    JamesRaynor
    Member

    thank you shalini,

    but i was using those tutorials, i have redone everything(thats java) and get the same result.

    one thing that i get is that when i retry to save a dao that already exists instead of not doing anything and keeping the database as is, it generates a new entry.

    for example if i enter in the state table:
    st_key = 1, name = abc
    and then do it again
    i get a table like:

    st_key | name
    1 | abc
    11 | abc
    12 | abc
    13 | abc
    and so on

    and i get that even if i change the key…
    is there something like an auto generate key on hibernate? or maybe its oracle?
    but i didn’t set my tables like that, but if so where can i check if i did?

    i am a complete noob on oracle, but i find it very useful. any web page or tutorial that you recommend????

    #312601 Reply

    JamesRaynor
    Member

    thank you shalini,

    but i was using those tutorials, i have redone everything(thats java) and get the same result.

    one thing that i get is that when i retry to save a dao that already exists instead of not doing anything and keeping the database as is, it generates a new entry.

    for example if i enter in the state table:
    st_key = 1, name = abc
    and then do it again
    i get a table like:

    st_key | name
    1 | abc
    11 | abc
    12 | abc
    13 | abc
    and so on

    and i get that even if i change the key…
    is there something like an auto generate key on hibernate? or maybe its oracle?
    but i didn’t set my tables like that, but if so where can i check if i did?

    i am a complete noob on oracle, but i find it very useful. any web page or tutorial that you recommend????

    #312607 Reply

    JamesRaynor
    Member

    ooops
    sorry about that i got a php error and thought that it didnt post

    #312663 Reply

    support-swapna
    Moderator

    This message has not been recovered.

    Attachments:
    You must be logged in to view attached files.
    #312706 Reply

    JamesRaynor
    Member

    This message has not been recovered.

    #312715 Reply

    support-swapna
    Moderator

    This message has not been recovered.

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: problem with primary key and hibernate and oracle

This topic is marked as closed to new replies, however your posting capabilities still allow you to do so.

You must be logged in to post in the forum log in