just to give a practical example, when such Tuple can be helpful in a 
typical SaaS that needs to work with JSON-columns.

---

When a new "Report" entry is created, the column "reportContentJson" must 
be filled with a nested json object consisting of specific! (not all) data 
from multiple other tables.

There is already an existing Repository that collects all relevant nested 
data from the multiple other tables as "Nested DTOs"

But for backwards-compatibility reasons the nested json must be "frozen" in 
regards to specific content (it should not contain all content)
So there are additional Nested DTOs needed, that only contain the data that 
is relevant to save into the json.

And now, when i want to create the NestedDTOs for the JSON-column from the 
NestedDTOs that contain all data,
the Tuple1, Tuple2, ..., TupleN can help me to create static constructors 
for creating the objects.

For example

class ReportContentJson {
   ...
   public static Nested1 create(Tuple2<SourceDTO, SubSourceDTO> rec) {
      return new Nested1()
         
.setReportContentSourceJson(ReportContentSourceJson.from(rec.value1()))
         
.setReportContentSubSourceJson(ReportContentSubSource.from(rec.value2()));
   }
}

class ReportContentSourceJson {
    ....
    public static ReportContentSourceJson from(SourceDTO dto) {
        return new ReportContentSourceJson()
            .setField1(dto.getField1())
            .setField2(dto.getField2());
    }
}

Bernd Huber schrieb am Freitag, 1. November 2024 um 15:11:19 UTC:

> when working with jOOQ, i embraced the use of Record1, Record2, ..., 
> RecordN when i pulled data out of the database, and used the convertFrom of 
> jooq where i convert those RecordN instances to my DTOs
>
> All in all i found it great to work that way.
>
> Java does not have Tuples (like RecordN) out of the box.
>
> Sometimes i create DTOs outside of the database-context,
> and it seems that RecordN can not be instantiiated manually so easily.
>
> I found the Tuple1, Tuple2, ..., TupleN in the jOOλ library, and they seem 
> to provide exactly what i need (using tuples that can be used everywhere in 
> the project for different purposes).
>
> Now, is there something in the jOOQ library already that i can use, or is 
> it good to use the jOOλ library for this purpose? 
>
>
>
>
>

-- 
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].
To view this discussion visit 
https://groups.google.com/d/msgid/jooq-user/8fd8fd32-7872-4635-bb97-4ad79ab48bc1n%40googlegroups.com.

Reply via email to