techPackets
techPackets

Reputation: 4504

@Parameter annotation in hibernate

I am trying a single one to one mapping example from this source

http://www.mkyong.com/hibernate/hibernate-one-to-one-relationship-example-annotation/

I don't understand what is the use of @Parameter in this code snippet.

@GenericGenerator(name = "generator", strategy = "foreign", 
    parameters = @Parameter(name = "property", value = "stock"))
    @Id
    @GeneratedValue(generator = "generator")
    @Column(name = "STOCK_ID", unique = true, nullable = false)
    public Integer getStockId() {
        return this.stockId;
    }

Can anyone please explain? Thanks

Upvotes: 0

Views: 4865

Answers (1)

Andriy Budzinskyy
Andriy Budzinskyy

Reputation: 2001

@Parameter annotation is used to configure the ID strategy. You use strategy="foreign" for one-to-one mapping between two entities. In this case you have specify foreing key as a parameter.

name = "property", value = "stock" points to 'stock' table.

Upvotes: 1

Related Questions