Can jOOQ object mapping configured ensure all fields of POJO are set? - jooq

I'm mapping jOOQ results into POJOs.
I'd like to avoid having columns of the result not being mapped because of a typo/mismatch between field name and column name.
Is there a way to configure jOOQ to verify each field of the POJO is properly set ?

This cannot be done out of the box, but you can implement a custom RecordMapperProvider that implements the desired checks:
https://www.jooq.org/doc/latest/manual/sql-execution/fetching/pojos-with-recordmapper-provider

Related

Dynamics CRM is ignoring the default value for two-option field

Quick question.
I have a custom two-option field on an entity, with "Yes"/"No" as the values; "Yes" has the underlying value 1, while "No" has the underlying value 0. I've set the default value for this field to "Yes". However, when I create new entity records, the field always gets the value "No" (0 in the database). It seems to be ignoring the default value I've set. Why?
The field is not present on any of the entity forms, as it's only used in underlying plugin code. Should that matter?
Are you creating a new record for this entity using code that uses the strongly-typed objects? If so, when you create a "new" entity in code, I'm guessing the class itself is setting that field to "false" by default. I don't think those generated classes respect the default values in the metadata. I also think that all fields are submitted on a create when you use these generated classes. That means that your class is setting it to "no" by default and then on create, the system thinks that you explicitly set it to "no" so default values are not applied. I think you need to explicitly remove that attribute from the attribute collection of your entity before you create it. That way the system should respect the default value on create. Sorry for all the "I thinks" but I'm not in a place that I can test or verify all of this. :)

How to use Automapper to map multiple DataTables to an object

I've used Automapper before to map DataTable objects to a DTO object like this:
AutoMapper.CreateMap<IDataReader, MyDTO>();
Now I've run into a case where I have three DataTable objects that map to one DTO object. I can't use the simple case above because I have three sources with the same type.
Is there a way to specify some additional information, like the table name, to determine the correct mapping?

Search filter using a bean's field values

Given a JSF/EJB stack, how do I filter the contents of a dataTable listing automatically using the values of a field in a pojo/entity bean?
i.e. I have an entity bean Employee with name field having a value of "John" I would like to use this bean to filter the data table to show only records with name John, and not having to construct the where clause manually?
I use PrimeFaces' dataTable with filtering and eventually lazy-Loading. Filtering alone is done at a client level, but lazy-loading is done at a server level.
Here you can find some examples.
Both are implemented with Ajax features by PrimeFaces: on typing each character, the filters are applied and the results updated.
With PrimeFaces' lazy-loading you have also the possibility to handle by yourself the filters: on typing a character in a filter, your implementation of the filter is invoked: with a little of Criteria Builder queries you can write the WHERE conditions in a type-safe and OO way, by building an array of Predicates: this implies that you don't need to write a single line of sql code.

How can I combine/split properties with AutoMapper?

we're using Automapper (http://automapper.codeplex.com/) to map between entities and dto's. We have a situation where one property on an entity corresponds to three different properties on the dto, and we need to write some custom logic to do the mapping. Anyone know how we can do that? (We need to map both ways, from entity and from dto).
I notice that AutoMapper supports custom resolvers to do custom mapping logic, but as far as I can tell from the documentation, they only allow you to map a single property to another single property.
Thx
You can create a custom type converter. It allows you to define a converter for an entire type, not just a single property.

ExecuteJoinedDataSet but with Where()

I did some searching and see that ExecuteJoinedDataSet will not work with the Where clause in 2.1. If I want to query a table with WHERE, but want the FK objects values to be bindable is the easiest way to just create a custom class(my table has tons of FK references).
Could you give us an example of what kind of query you are trying to write? If you are just trying to return a DataTable without creating a custom class just write your query and use the ExecuteReader which Returns an IDataReader. The IDataReader is bindable and if you need more you can just load it into a DataTable.

Resources