Generator classes in Hibernate
The <generator> class is a sub-component of id. It is utilized to create the one of a kind identifier for the objects of tenacious class. There are numerous generator classes characterized in the Hibernate Framework.
All the generator classes implements the org.hibernate.id.IdentifierGenerator interface. The application software programmer may make one's very own generator classes by executing the IdentifierGenerator interface. Hibernate framework gives many built-in generator classes:
It is the default generator strategy if there is no <generator> element . In this case, application assigns the id. For example:
It generates the unique id only if no other process is inserting data into this table. It generates short, int or long type identifier. If a table contains an identifier then the application considers its maximum value else the application consider that the first generated identifier is 1. For each attribute value, the hibernate increment the identifier by 1. Syntax:
It utilizes the sequence of the database. in the event that there is no arrangement characterized, it makes a sequence consequently for example if there should be an occurrence of Oracle database, it makes an arrangement named HIBERNATE_SEQUENCE. If there should arise an occurrence of Oracle, DB2, SAP DB, Postgre SQL or McKoi, it utilizes sequence however it utilizes generator in interbase. Syntax:
For characterizing your very own succession, utilize the param subelement of generator.
It utilizes high and low algorithm to create the id of sort short, int and long. Sentence structure:
It utilizes character, sequence or hilo relying upon the database seller. Sentence structure:
It is utilized in Sybase, My SQL, MS SQL Server, DB2 and HypersonicSQL to help the id column. The returned id is of sort short, int or long. It is duty of database to create special identifier.
It utilizes high and low algorithm on the predetermined sequence name. The returned id is of sort short, int or long.
It utilizes 128-piece UUID algorithm to create the id. The returned id is of sort String, one of a kind inside a system (since IP is utilized). The UUID is spoken to in hexadecimal digits, 32 long.
|It utilizes GUID created by database of sort string. It chips away at MS SQL Server and MySQL.|
|It utilizes the essential key returned by the database trigger.|
|It utilizes the id of another related item, for the most part utilized with <one-to-one> affiliation.|
12) arrangement identity
|It utilizes an special sequence age strategy. It is upheld in Oracle 10g drivers only.|