3

I have this mapping in my code:

News.hbm.xml:
<class name="xyz.News" table="XYZ_NEWS">
        <id name="id" column="NEWS_ID">
            <generator class="native"/>
        </id>
rest of mapping
</class>

I am using Oracle database. Hibernate documentation tells me:

native - selects identity, sequence or hilo depending upon the capabilities of the underlying database

What does that mean for Oracle?

Edit: I know now it uses sequences. The name of the sequence is what i am interested in.

1
  • 2
    this link may help you. Commented Aug 26, 2011 at 9:52

2 Answers 2

8

It takes sequences. You need to provide a sequence name.
Edit: If name is not provided, sequence named HIBERNATE_SEQUENCE is going to be used.

Looking at the code, it lets the dialect decide. The Dialect implements the decision like this:

// Dialect.cs Line 231
public virtual System.Type NativeIdentifierGeneratorClass
{
    get
    {
        if (SupportsIdentityColumns)
        {
            return typeof(IdentityGenerator);
        }
        else if (SupportsSequences)
        {
            return typeof(SequenceGenerator);
        }
        else
        {
            return typeof(TableHiLoGenerator);
        }
    }
}

It isn't overriden by Oracle. Oracle doesn't support identity, but sequences.

Sign up to request clarification or add additional context in comments.

Comments

1

It's quite simple: Your generator will use identity or sequence columns according to what your current database support:

For example Oracle has sequences but previous versions of MS SQL server don't.

You can read more about differences between identities and sequences in this article: http://sqlserver-training.com/what-is-the-difference-between-identity-and-sequence/-

The native generator always returns long, short or integer values:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.