Reputation: 12999
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.
Upvotes: 3
Views: 23461
Reputation: 64628
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.
Upvotes: 8
Reputation: 18639
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:
Upvotes: 1