91-9990449935 0120-4256464 |
Generator classes in HibernateThe <generator> subelement of id used to generate the unique identifier for the objects of persistent class. There are many generator classes defined in the Hibernate Framework. All the generator classes implements the org.hibernate.id.IdentifierGenerator interface. The application programmer may create one's own generator classes by implementing the IdentifierGenerator interface. Hibernate framework provides many built-in generator classes:
1) assignedIt is the default generator strategy if there is no <generator> element . In this case, application assigns the id. For example: 2) incrementIt generates the unique id only if no other process is inserting data into this table. It generates short, int or long type identifier. The first generated identifier is 1 normally and incremented as 1. Syntax: 3) sequenceIt uses the sequence of the database. if there is no sequence defined, it creates a sequence automatically e.g. in case of Oracle database, it creates a sequence named HIBERNATE_SEQUENCE. In case of Oracle, DB2, SAP DB, Postgre SQL or McKoi, it uses sequence but it uses generator in interbase. Syntax: For defining your own sequence, use the param subelement of generator. 4) hiloIt uses high and low algorithm to generate the id of type short, int and long. Syntax: 5) nativeIt uses identity, sequence or hilo depending on the database vendor. Syntax: 6) identityIt is used in Sybase, My SQL, MS SQL Server, DB2 and HypersonicSQL to support the id column. The returned id is of type short, int or long. 7) seqhiloIt uses high and low algorithm on the specified sequence name. The returned id is of type short, int or long. 8) uuidIt uses 128-bit UUID algorithm to generate the id. The returned id is of type String, unique within a network (because IP is used). The UUID is represented in hexadecimal digits, 32 in length. 9) guid
10) select
11) foreign
12) sequence-identity
Next TopicDialects In Hibernate
|