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.










share|improve this question






















  • 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















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.










share|improve this question






















  • 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













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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












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.






share|improve this answer





















  • Thanks for pointing it out, indeed above sections cover all about request binding and validation.
    – Aditya Thakur
    Nov 22 at 5:43











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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.






share|improve this answer





















  • Thanks for pointing it out, indeed above sections cover all about request binding and validation.
    – Aditya Thakur
    Nov 22 at 5:43















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.






share|improve this answer





















  • Thanks for pointing it out, indeed above sections cover all about request binding and validation.
    – Aditya Thakur
    Nov 22 at 5:43













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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin