Hi Max,

I'm afraid I can't get your example to compile. It has two getId() getters,
which is not valid Java. To rule out any possible testing side effects on
your side, would you mind providing an MCVE (minimal complete verifiable
example) from this template here:
https://github.com/jOOQ/jOOQ-mcve

Thank you very much,
Lukas

On Thu, Jan 17, 2019 at 5:54 PM Max Kremer <[email protected]> wrote:

>
> Hi Lukas,
>
>   Here is a simple example to recreate the issue:
>
>
> The schema
> CREATE TABLE foo as ( id integer, name text);
>
> INSERT INTO foo values (1, 'foo'), (2, 'bar'), (3, 'baz');
>
>
> The pojo with annotations:
>
> package models;
>
>
> import javax.persistence.Column;
>
>
> public class Foo {
>
> private String name;
> private int id;
> private String helper;
>
>        //NO default constructor
> public Foo(String helper) {
> this.helper = helper;
> }
> public String getName() {
> return name;
> }
>
> public int getId() {
> return id;
> }
> @Column(name="name")
> public void setName(String name) {
> this.name = name;
> }
> public int getId() {
> return id;
> }
> @Column(name="id")
> public void setId(int id) {
> this.id = id;
> }
> }
>
>
> The code that throws the exception (I've glossed over the part that gets
> the dslcontext, i dont think its important here... )
>
> DSLContext d;
> ...
>
>
> d.resultQuery("select id, name from foo" ).fetch(r -> r.into(new Foo(
> "helper")));
>
>
>
> The above code throws:
> *org.jooq.exception.MappingException: No matching constructor found on
> type class models.Foo for record org.jooq.impl.DefaultRecordMapper@3b059fb0*
>
> However if I add a default constructor to class Foo everything works.
>
> public Foo() {
>     //empty default constructor
> }
>
>
> Again I find this strange because I'm providing the mapper an instance of
> my class, why does it need to care about the constructor? Hope this example
> helps.
>
> -Max
>
>
> On Thursday, January 17, 2019 at 12:06:22 AM UTC-6, Lukas Eder wrote:
>>
>> Hi Max,
>>
>> I would need a more complete example to help reproduce this issue.
>>
>> Thanks,
>> Lukas
>>
>> On Wed, Jan 16, 2019 at 10:16 PM Max Kremer <[email protected]> wrote:
>>
>>> Hey, sorry for reviving this thread but i noticed some strange behaviour.
>>>
>>> I get an exception:
>>>
>>> No matching constructor found on type class models.MyRow for record
>>> org.jooq.impl.DefaultRecordMapper
>>>
>>> when using .fetch(r -> r.into(new MyRow(helper)));
>>>
>>> Why would it be looking for a constructor when I'm passing in instance
>>> of MyRow?
>>>
>>> This issue is resolved when I add a default constructor:
>>>
>>> public MyRow()  { }
>>>
>>> Again, strange since I'm passing an already constructed instance to the
>>> record mapper. Could you please shed some light on this?
>>>
>>>
>>>
>>> On Wednesday, January 2, 2019 at 6:59:21 AM UTC-6, Lukas Eder wrote:
>>>>
>>>> Yes of course, thanks for the correction
>>>>
>>>> On Sat, Dec 29, 2018 at 8:30 PM Max Kremer <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> Correction.
>>>>>
>>>>> .fetchInto(r -> r.into(new MyRow(helper)));
>>>>> vs
>>>>> .fetchInto(MyRow.class);
>>>>>
>>>>>
>>>>> The RowMapper example above should read
>>>>>
>>>>> .fetch(r -> r.into(new MyRow(helper)));
>>>>>
>>>>>
>>>>>
>>>>>>> --
>>>>> 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.
>>>>>
>>>> --
>>> 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.
>>>
>> --
> 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.
>

-- 
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.

Reply via email to