Yes, it is possible to personalize the names of columns in an abstract domain class using Grails. This can be done by using the static mapping
block in the domain class and specifying a column
attribute for each property that needs to be customized.
For example, suppose we have an abstract domain class Person
:
abstract class Person {
String firstName
String lastName
}
If we want to customize the column names for firstName
and lastName
, we can do it like this:
abstract class Person {
String firstName
String lastName
static mapping = {
firstName column: 'first_name'
lastName column: 'last_name'
}
}
This will create columns named first_name
and last_name
in the database table for each subclass of Person
.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-30 00:09:16 +0000
Seen: 7 times
Last updated: May 30 '23