bobby
bobby

Reputation: 2789

How to autogenerate a Panache entity

Is it possible to auto generate Panache entities from existing database tables in eclipse/any other environment.?
I am trying out quarkus, and have a database with a number of tables and would like to auto generate the entity code

Upvotes: 1

Views: 1819

Answers (1)

loicmathieu
loicmathieu

Reputation: 5562

Panache entities are JPA entities with an extends PanacheEntity or extends PanacheEntityBase at the type decaration site.

You can generate your JPA entities, both Eclipse and ItelliJ IDEA have plugins for that, then add the extends clause.

Be carefull that if you extends PanacheEntity you should use the default id strategy that it provides (an autogenerated Long id), so better extends PanacheEntityBase if you generates from an existing schema.

Panache also provides a repository approach that can be useful if you don't want to update your entity after generation.

Upvotes: 2

Related Questions