Hello guys,

i wonder how you guys are defining your Business Models (DTOs) for the 
different use-cases and how you are defining the constructors of the DTOs 
for use with the Jooq Typesafe Api (convertFrom, Records.mapping, mapping, 
...)

For example:

My DTOs have 3 kinds of fields:
- Simple Database-Fields (Integer, String, BigDecimal, ...) created by the 
Codegen
- Complex Database-Fields resolved by Joins (UserDTO, List<ProductLangDTO>, 
...) not! created by the Codegen
- Control Fields with no direct relation to the database (deleteFlag=true, 
insertFlag=true)

Should the DTO Constructors contain all those fields, or only those fields 
that are needed for the Jooq Typesafe Mapping ? 

Do i need to create multiple DTO Constructory for different use-cases of 
Queries ? For example:
- Query1 gets all products with all langs and the user
- Query2 gets only one product, and only some fields of it

Would i need to define a constructor for Query1 and a constructor for 
Query2 or should i defined two separate ProductDTOs (one with only the 
fields for query1, and one with only the fields for query2) ? 

Has someone also got experience with those questions and how to solve them? 

Before using the Jooq Typesafe API i always did the "into()" mapping, where 
those questions were not relevant because everything was automagically 
mapped. But typesafety benefits are pretty important i think, so i now try 
to use the typesafe api more. 

I also wonder if my way ot using the "into()" mapping is safe enough. I 
sometimes have no other choice but to use "into()" to make AbstractDAO 
Abstraction possible. 

I always do: 

// first: map to codegenerated jooq-table
- ProductRecord rec = record.into(Product)  
// second: map to DTO which implements the same interface 
- rec.into(ProductDTO.class) as the ProductRecord (should be safe)

somehow i assume that with this kind of two-way "into()" jooq should be 
able to always reflect correctly (at least it did for me always when i did 
it that way.

When i map "record.into(ProductDTO.class)" this is dangerous though, 
because sometimes the reflect-api would reflect fields from an other 
joined-table with the same name (clientId) into the wrong DTO. So this way 
to reflect directly seems to be dangerous.

Sorry for asking so many stuff, but maybe someone has some ideas or already 
solved those questions ;)











-- 
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 jooq-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/21b9499f-4568-4621-8a64-24d2643f1dean%40googlegroups.com.

Reply via email to