Lukas,
Thanks for responding, what I had to do to solve the issue I described was
create classes that represent a form on the page instead of using the
generated jooq models.
For instance:
public class PersonEditForm {
public Integer id;
@Constraints.Required
@Constraints.MaxLength(45)
public String firstName;
@Constraints.MaxLength(45)
public String middleName;
@Constraints.Required
@Constraints.MaxLength(45)
public String lastName;
}
>From there, I have to write a mapper that takes a pojo from jooq and maps
it into this form when editing the person. I also have to take that same
class and write jooq update/insert statements manually to get around the
issue of updating my createDate and modifiedDate to invalid values. For
example below:
jooq.dsl().update(PERSON_TABLE)
.set(PERSON_TABLE.FIRSTNAME, form.getFirstName())
.where(EVALUATIONS_TABLE.ID.equal(evaluationForm.id));
On Wednesday, April 13, 2016 at 1:38:46 AM UTC-5, Lukas Eder wrote:
>
> Hi Scott,
>
> Thank you very much for your enquiry. I'd love to learn more about how you
> "autowired" Play validation to jOOQ records (or POJOs). How does that work?
> Do you need to write any additional boilerplate code around what jOOQ is
> generating, or does that mostly work out of the box?
>
> I will answer your questions inline:
>
> 2016-04-13 0:16 GMT+02:00 <[email protected] <javascript:>>:
>
>> I am using the play framework along with jooq to autogenerate my
>> datatable,dao, and pojo objects. When creating a form for the page to post
>> data using the form helpers from play, I can validate the form that was
>> posted and save the record if no validation errors were found. The issue
>> I'm having is dealing with an edit page where I have mapped 2 database
>> fields for createdDate and modifiedDate which are timestamps in a mysql DB.
>>
>>
>> When I validate the form that is bound from the request parameters, it
>> has errors for the created and modified fields. These fields in the
>> textbox are shown as mm/dd/yyyy without a time element to it, so I assume
>> that the play framework request binder isn't able to bind from a string
>> date to the timestamp type, or I'm doing something wrong.
>>
>> Before I get into a specific question, I would rather solve this problem
>> the right way, is using a timestamp the wrong solution?
>>
>
> Timestamp is perfect for jOOQ / JDBC (if your database column has the
> semantics of the SQL TIMESTAMP WITHOUT TIME ZONE data type). But perhaps,
> Play cannot handle automatic data type conversion for the
> java.sql.Timestamp type? In that case, you could use a more appropriate
> data type also in jOOQ, either by using converters or data type bindings.
> Converters will probably be sufficient for this case:
>
> http://www.jooq.org/doc/latest/manual/code-generation/custom-data-types
>
> http://www.jooq.org/doc/latest/manual/code-generation/custom-data-type-bindings
>
>
>> Is it typically best practice to make the created and modified dates
>> DateTime?
>>
>
> Yeah, why not?
>
>
>> When I added the following code to my jooq xml I've was able to work
>> around the validation issue because my pojo no longer had the fields for
>> created and modified:
>>
>> <includeExcludeColumns>true</includeExcludeColumns>
>>
>> <excludes>created|modified</excludes>
>>
>>
>> The issue with the solution is that I can now save and get pass the
>> validation issues, but now the queries where I needed the value for
>> created/modified dates no longer work because the generated classes no
>> longer have those properties.
>>
>
> Indeed. Doing that will make jOOQ behave as though those columns don't
> even exist in your table. That's probably not what you want.
>
> Lukas
>
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.