Hibernate: ID generator using increment and Oracle Schema

后端 未结 2 1167
余生分开走
余生分开走 2021-01-06 10:31

I am using Hiberbnate 3.1.3. I have a mapping as below and when I try to insert a record into the TEST_TABLE, I get an Exception: \'Exception in thread \"main\" org.hibernat

相关标签:
2条回答
  • 2021-01-06 10:33

    You can specify schema for your generator using schema parameter:

    <generator class="increment">
        <param name="schema">TEST</param>
    </generator>
    

    Sadly, this is not well described in Hibernate documentation; you'd have to look at the API javadoc in order to find that out.

    That said, Mark is right with regards to "increment" not being very efficient - it's also not safe in a cluster environment.

    0 讨论(0)
  • 2021-01-06 10:54

    If the hibernate default schema is OTHER_SCHEMA then if you do not supply a schema for a table then it will automatically add the default

    Solution is you have to add a schema for all table names except one the default. In this case you might be better off if you set the hibernate default to your schema.

    Looking at the sequence using max(id) like that is not usually efficient, especially in Oracle which has sequences exactly for this use.

    0 讨论(0)
提交回复
热议问题