How to retrieve post data, validate it in controller and save it in database using GORM in Micronaut?
up vote
1
down vote
favorite
I come from Grails background and have recently started a project in Micronaut using GORM.
I tried to find required information in documentation but its not clear how we retrieve post data in controller, validate it similar to Command Objects offered in Grails and save it into database using interface service provided in documentation
PS : I know I can map every field to action argument in controller, and also declare a interface method specifying each argument as property but that does not seems right thing to do as my domain class has so many properties.
Making the action @Transactional or any method would work for saving data as far as I know but I want to know the proper way in Micronaut.
My requirement is simple, save post data in database using GORM in Micronaut.
groovy gorm micronaut
add a comment |
up vote
1
down vote
favorite
I come from Grails background and have recently started a project in Micronaut using GORM.
I tried to find required information in documentation but its not clear how we retrieve post data in controller, validate it similar to Command Objects offered in Grails and save it into database using interface service provided in documentation
PS : I know I can map every field to action argument in controller, and also declare a interface method specifying each argument as property but that does not seems right thing to do as my domain class has so many properties.
Making the action @Transactional or any method would work for saving data as far as I know but I want to know the proper way in Micronaut.
My requirement is simple, save post data in database using GORM in Micronaut.
groovy gorm micronaut
Did you look at Handling Form Data? I have not tried this yet, but it is something I will need to do soon. I wonder if the Domain object can be used as the @Body argument. You will probably have to do the find() and update in your code.
– Mike Houston
Nov 18 at 22:58
I am looking into that, will let you know if that works.
– Aditya Thakur
Nov 19 at 5:32
1
Damm, people downvote questions without even telling the reason for downvote :(
– Aditya Thakur
Nov 19 at 5:35
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I come from Grails background and have recently started a project in Micronaut using GORM.
I tried to find required information in documentation but its not clear how we retrieve post data in controller, validate it similar to Command Objects offered in Grails and save it into database using interface service provided in documentation
PS : I know I can map every field to action argument in controller, and also declare a interface method specifying each argument as property but that does not seems right thing to do as my domain class has so many properties.
Making the action @Transactional or any method would work for saving data as far as I know but I want to know the proper way in Micronaut.
My requirement is simple, save post data in database using GORM in Micronaut.
groovy gorm micronaut
I come from Grails background and have recently started a project in Micronaut using GORM.
I tried to find required information in documentation but its not clear how we retrieve post data in controller, validate it similar to Command Objects offered in Grails and save it into database using interface service provided in documentation
PS : I know I can map every field to action argument in controller, and also declare a interface method specifying each argument as property but that does not seems right thing to do as my domain class has so many properties.
Making the action @Transactional or any method would work for saving data as far as I know but I want to know the proper way in Micronaut.
My requirement is simple, save post data in database using GORM in Micronaut.
groovy gorm micronaut
groovy gorm micronaut
asked Nov 18 at 19:52
Aditya Thakur
162112
162112
Did you look at Handling Form Data? I have not tried this yet, but it is something I will need to do soon. I wonder if the Domain object can be used as the @Body argument. You will probably have to do the find() and update in your code.
– Mike Houston
Nov 18 at 22:58
I am looking into that, will let you know if that works.
– Aditya Thakur
Nov 19 at 5:32
1
Damm, people downvote questions without even telling the reason for downvote :(
– Aditya Thakur
Nov 19 at 5:35
add a comment |
Did you look at Handling Form Data? I have not tried this yet, but it is something I will need to do soon. I wonder if the Domain object can be used as the @Body argument. You will probably have to do the find() and update in your code.
– Mike Houston
Nov 18 at 22:58
I am looking into that, will let you know if that works.
– Aditya Thakur
Nov 19 at 5:32
1
Damm, people downvote questions without even telling the reason for downvote :(
– Aditya Thakur
Nov 19 at 5:35
Did you look at Handling Form Data? I have not tried this yet, but it is something I will need to do soon. I wonder if the Domain object can be used as the @Body argument. You will probably have to do the find() and update in your code.
– Mike Houston
Nov 18 at 22:58
Did you look at Handling Form Data? I have not tried this yet, but it is something I will need to do soon. I wonder if the Domain object can be used as the @Body argument. You will probably have to do the find() and update in your code.
– Mike Houston
Nov 18 at 22:58
I am looking into that, will let you know if that works.
– Aditya Thakur
Nov 19 at 5:32
I am looking into that, will let you know if that works.
– Aditya Thakur
Nov 19 at 5:32
1
1
Damm, people downvote questions without even telling the reason for downvote :(
– Aditya Thakur
Nov 19 at 5:35
Damm, people downvote questions without even telling the reason for downvote :(
– Aditya Thakur
Nov 19 at 5:35
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
If I were you I would look back at the documentation, sections 6.4 to 6.11:
https://docs.micronaut.io/snapshot/guide/index.html#binding
https://docs.micronaut.io/snapshot/guide/index.html#datavalidation
http://hibernate.org/validator/
Micronaut is very annotation based, unlike Grails which uses convention over configuration. However in Grails 4, Micronaut will toke over the application context, giving you some of the benefits of Micronaut, but still maintaining the convention over configuration.
Thanks for pointing it out, indeed above sections cover all about request binding and validation.
– Aditya Thakur
Nov 22 at 5:43
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
If I were you I would look back at the documentation, sections 6.4 to 6.11:
https://docs.micronaut.io/snapshot/guide/index.html#binding
https://docs.micronaut.io/snapshot/guide/index.html#datavalidation
http://hibernate.org/validator/
Micronaut is very annotation based, unlike Grails which uses convention over configuration. However in Grails 4, Micronaut will toke over the application context, giving you some of the benefits of Micronaut, but still maintaining the convention over configuration.
Thanks for pointing it out, indeed above sections cover all about request binding and validation.
– Aditya Thakur
Nov 22 at 5:43
add a comment |
up vote
1
down vote
accepted
If I were you I would look back at the documentation, sections 6.4 to 6.11:
https://docs.micronaut.io/snapshot/guide/index.html#binding
https://docs.micronaut.io/snapshot/guide/index.html#datavalidation
http://hibernate.org/validator/
Micronaut is very annotation based, unlike Grails which uses convention over configuration. However in Grails 4, Micronaut will toke over the application context, giving you some of the benefits of Micronaut, but still maintaining the convention over configuration.
Thanks for pointing it out, indeed above sections cover all about request binding and validation.
– Aditya Thakur
Nov 22 at 5:43
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
If I were you I would look back at the documentation, sections 6.4 to 6.11:
https://docs.micronaut.io/snapshot/guide/index.html#binding
https://docs.micronaut.io/snapshot/guide/index.html#datavalidation
http://hibernate.org/validator/
Micronaut is very annotation based, unlike Grails which uses convention over configuration. However in Grails 4, Micronaut will toke over the application context, giving you some of the benefits of Micronaut, but still maintaining the convention over configuration.
If I were you I would look back at the documentation, sections 6.4 to 6.11:
https://docs.micronaut.io/snapshot/guide/index.html#binding
https://docs.micronaut.io/snapshot/guide/index.html#datavalidation
http://hibernate.org/validator/
Micronaut is very annotation based, unlike Grails which uses convention over configuration. However in Grails 4, Micronaut will toke over the application context, giving you some of the benefits of Micronaut, but still maintaining the convention over configuration.
answered Nov 19 at 12:32
virtualdogbert
23616
23616
Thanks for pointing it out, indeed above sections cover all about request binding and validation.
– Aditya Thakur
Nov 22 at 5:43
add a comment |
Thanks for pointing it out, indeed above sections cover all about request binding and validation.
– Aditya Thakur
Nov 22 at 5:43
Thanks for pointing it out, indeed above sections cover all about request binding and validation.
– Aditya Thakur
Nov 22 at 5:43
Thanks for pointing it out, indeed above sections cover all about request binding and validation.
– Aditya Thakur
Nov 22 at 5:43
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364838%2fhow-to-retrieve-post-data-validate-it-in-controller-and-save-it-in-database-usi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you look at Handling Form Data? I have not tried this yet, but it is something I will need to do soon. I wonder if the Domain object can be used as the @Body argument. You will probably have to do the find() and update in your code.
– Mike Houston
Nov 18 at 22:58
I am looking into that, will let you know if that works.
– Aditya Thakur
Nov 19 at 5:32
1
Damm, people downvote questions without even telling the reason for downvote :(
– Aditya Thakur
Nov 19 at 5:35