Matching foreign keys
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
The following example shows how to define a MatcherStrategy for generated org.jooq.ForeignKey
types and related objects:
<configuration> <!-- These properties can be added directly to the generator element: --> <generator> <strategy> <matchers> <!-- Specify 0..n foreign key matchers to provide a strategy for naming objects created from foreign keys. --> <foreignKeys> <foreignKey> <!-- Match unqualified or qualified foreign key names. If left empty, this matcher applies to all foreign keys. --> <expression>MY_FK_NAME</expression> <!-- This influences the identifier in the generated Keys class --> <keyIdentifier> a MatcherRule specification </keyIdentifier> <!-- The method name generated for to-one path joins. --> <pathMethodName> a MatcherRule specification </pathMethodName> <!-- The method name generated for to-many path joins. --> <pathMethodNameInverse> a MatcherRule specification </pathMethodNameInverse> <!-- The method name generated for many-to-many path joins. --> <pathMethodNameManyToMany> a MatcherRule specification </pathMethodNameManyToMany> </foreignKey> </foreignKeys> </matchers> </strategy> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() // These properties can be added directly to the generator element: .withGenerator(new Generator() .withStrategy(new Strategy() .withMatchers(new Matchers() // Specify 0..n foreign key matchers to provide a strategy for naming objects created from foreign keys. .withForeignKeys( new MatchersForeignKeyType() // Match unqualified or qualified foreign key names. If left empty, this matcher applies to all foreign keys. .withExpression("MY_FK_NAME") // This influences the identifier in the generated Keys class .withKeyIdentifier(MatcherRule. a MatcherRule specification ) // The method name generated for to-one path joins. .withPathMethodName(MatcherRule. a MatcherRule specification ) // The method name generated for to-many path joins. .withPathMethodNameInverse(MatcherRule. a MatcherRule specification ) // The method name generated for many-to-many path joins. .withPathMethodNameManyToMany(MatcherRule. a MatcherRule specification ) ) ) ) )
See the configuration XSD and programmatic code generation for more details.
import org.jooq.meta.jaxb.* configuration { // These properties can be added directly to the generator element: generator { strategy { matchers { // Specify 0..n foreign key matchers to provide a strategy for naming objects created from foreign keys. foreignKeys { foreignKey { // Match unqualified or qualified foreign key names. If left empty, this matcher applies to all foreign keys. expression = "MY_FK_NAME" // This influences the identifier in the generated Keys class keyIdentifier = MatcherRule. a MatcherRule specification // The method name generated for to-one path joins. pathMethodName = MatcherRule. a MatcherRule specification // The method name generated for to-many path joins. pathMethodNameInverse = MatcherRule. a MatcherRule specification // The method name generated for many-to-many path joins. pathMethodNameManyToMany = MatcherRule. a MatcherRule specification } } } } } }
See the configuration XSD and gradle code generation for more details.
configuration { // These properties can be added directly to the generator element: generator { strategy { matchers { // Specify 0..n foreign key matchers to provide a strategy for naming objects created from foreign keys. foreignKeys { foreignKey { // Match unqualified or qualified foreign key names. If left empty, this matcher applies to all foreign keys. expression = "MY_FK_NAME" // This influences the identifier in the generated Keys class keyIdentifier = " a MatcherRule specification " // The method name generated for to-one path joins. pathMethodName = " a MatcherRule specification " // The method name generated for to-many path joins. pathMethodNameInverse = " a MatcherRule specification " // The method name generated for many-to-many path joins. pathMethodNameManyToMany = " a MatcherRule specification " } } } } } }
See the configuration XSD and gradle code generation for more details.
generationTool { // These properties can be added directly to the generator element: generator { strategy { matchers { // Specify 0..n foreign key matchers to provide a strategy for naming objects created from foreign keys. foreignKeys { foreignKey { // Match unqualified or qualified foreign key names. If left empty, this matcher applies to all foreign keys. expression = "MY_FK_NAME" // This influences the identifier in the generated Keys class keyIdentifier = " a MatcherRule specification " // The method name generated for to-one path joins. pathMethodName = " a MatcherRule specification " // The method name generated for to-many path joins. pathMethodNameInverse = " a MatcherRule specification " // The method name generated for many-to-many path joins. pathMethodNameManyToMany = " a MatcherRule specification " } } } } } }
See the configuration XSD and gradle code generation for more details.
As always, when regular expressions are used, they are regular expressions with default flags.
See MatcherRule for more information about MatcherRule
specifications.
Feedback
Do you have any feedback about this page? We'd love to hear it!