arnaudroger / SimpleFlatMapper

Fast and Easy mapping from database and csv to POJO. A java micro ORM, lightweight alternative to iBatis and Hibernate. Fast Csv Parser and Csv Mapper
http://simpleflatmapper.org
MIT License
440 stars 76 forks source link

JOOQ/Could not find eligible property #702

Open javaboyjunior opened 4 years ago

javaboyjunior commented 4 years ago

Hi there

Trying to figure out what I am doing wrong without providing tons of code. I have a JOOQ generated POJO that has the following field definition:

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "farmer_id", nullable = false, precision = 20)
public ULong getFarmerId() {
    return this.farmerId;
}

for the following column definition: farmer_id SERIAL PRIMARY KEY,

I am running the following query:

    SelectQueryMapper<Farmer> farmerMapper = SelectQueryMapperFactory
            .newInstance()
            .newMapper(Farmer.class);

    List<Farmer> farmers = farmerMapper.asList(dslContext
            .select(FARMER.FARMER_ID, FARMER.LEGACY_ID, FARMER.COMPANY_NAME, FARMER.CONTACT_FIRST,
                    FARMER.CONTACT_LAST, FARMER.ADDRESS, FARMER.CITY, FARMER.STATE_ID,
                    FARMER.ZIP, FARMER.PHONE, FARMER.EMAIL, FARMER.WEBSITE,
                    FARMER.FARMER_TYPE_ID, FARMER.ACTIVE, FARMER.DB_DATE_CREATED, FARMER.DB_DATE_UPDATED,
                    FARMER_TYPE.FARMER_TYPE_ID, FARMER_TYPE.NAME, FARMER_TYPE.DB_DATE_CREATED,
                    FARMER_TYPE.DB_DATE_UPDATED)
            .from(FARMER).leftJoin(FARMER_TYPE).on(FARMER_TYPE.FARMER_TYPE_ID.eq(FARMER.FARMER_TYPE_ID))
            .orderBy(FARMER.COMPANY_NAME));
    return farmers;

and I get the following exception:

org.jooq.exception.MappingException: Could not find eligible property for 'farmer_id' on class org.aim.core.persistence.tables.pojos.Farmer not found

I have tried adding an alias for the farmer_id to farmerId and that doesn't make any difference. I must be missing something but can't figure out what. As far as I can tell from the docs, my property and column names meet the criteria for name matching without aliases. Any thoughts as to what I am doing wrong? Thank you.

arnaudroger commented 4 years ago

Thanks for the report will have a look at it

arnaudroger commented 4 years ago

Is there a setter or a constructor that’s can set the farmerId?

javaboyjunior commented 4 years ago

First of all, thanks for the quick response!

farmerId does have a setter. Here's the full declaration:

@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "farmer_id", nullable = false, precision = 20) public ULong getFarmerId() { return this.farmerId; }

public void setFarmerId(ULong farmerId) { this.farmerId = farmerId; }

Thank you!

On Mon, Jan 6, 2020 at 2:36 AM Arnaud Roger notifications@github.com wrote:

Is there a setter or a constructor that’s can set the farmerId?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arnaudroger/SimpleFlatMapper/issues/702?email_source=notifications&email_token=AAD7U2NRMS3EGLE7YN7UA7DQ4MCSZA5CNFSM4KC7NF52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIFCFOY#issuecomment-571089595, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7U2PCV37GANG33T7HOX3Q4MCSZANCNFSM4KC7NF5Q .

javaboyjunior commented 4 years ago

Update: I tried removing the join so was just selecting a flat list of farmers without inflating any foreign key POJOs and got the same error.

arnaudroger commented 4 years ago

That might because of the ulong could you try with just a regular long to see if that the case. I’ll might need to add the support for that. I don’t have much time this week to look at that though so on a more thorough look next week

javaboyjunior commented 4 years ago

Yes, it was the ULong- thanks. I can convert my code to longs easily enough. If you want to point me in a general direction I could attempt a PR if you like :-)

On Tue, Jan 7, 2020 at 10:38 AM Arnaud Roger notifications@github.com wrote:

That might because of the ulong could you try with just a regular long to see if that the case. I’ll might need to add the support for that. I don’t have much time this week to look at that though so on a more thorough look next week

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arnaudroger/SimpleFlatMapper/issues/702?email_source=notifications&email_token=AAD7U2KD76IWYZWPIZ2FHBDQ4TD3HA5CNFSM4KC7NF52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIJ3ACA#issuecomment-571715592, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7U2KK5Y5CFWCHIWQBQJLQ4TD3HANCNFSM4KC7NF5Q .

arnaudroger commented 4 years ago

I’ll keep the ticket open and try to add support for Uxxx

Sent from my iPhone

On 7 Jan 2020, at 19:44, Mike Cahill notifications@github.com wrote:

Yes, it was the ULong- thanks. I can convert my code to longs easily enough. If you want to point me in a general direction I could attempt a PR if you like :-)

On Tue, Jan 7, 2020 at 10:38 AM Arnaud Roger notifications@github.com wrote:

That might because of the ulong could you try with just a regular long to see if that the case. I’ll might need to add the support for that. I don’t have much time this week to look at that though so on a more thorough look next week

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arnaudroger/SimpleFlatMapper/issues/702?email_source=notifications&email_token=AAD7U2KD76IWYZWPIZ2FHBDQ4TD3HA5CNFSM4KC7NF52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIJ3ACA#issuecomment-571715592, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7U2KK5Y5CFWCHIWQBQJLQ4TD3HANCNFSM4KC7NF5Q .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

javaboyjunior commented 4 years ago

Thank you sir.

On Wed, Jan 8, 2020 at 10:17 AM Arnaud Roger notifications@github.com wrote:

I’ll keep the ticket open and try to add support for Uxxx

Sent from my iPhone

On 7 Jan 2020, at 19:44, Mike Cahill notifications@github.com wrote:

Yes, it was the ULong- thanks. I can convert my code to longs easily enough. If you want to point me in a general direction I could attempt a PR if you like :-)

On Tue, Jan 7, 2020 at 10:38 AM Arnaud Roger notifications@github.com wrote:

That might because of the ulong could you try with just a regular long to see if that the case. I’ll might need to add the support for that. I don’t have much time this week to look at that though so on a more thorough look next week

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/arnaudroger/SimpleFlatMapper/issues/702?email_source=notifications&email_token=AAD7U2KD76IWYZWPIZ2FHBDQ4TD3HA5CNFSM4KC7NF52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIJ3ACA#issuecomment-571715592 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAD7U2KK5Y5CFWCHIWQBQJLQ4TD3HANCNFSM4KC7NF5Q

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arnaudroger/SimpleFlatMapper/issues/702?email_source=notifications&email_token=AAD7U2I2SOPD3A25EIQM46TQ4YKCXA5CNFSM4KC7NF52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEINPL2Y#issuecomment-572192235, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7U2PQ2XYV5BUQEPX6W23Q4YKCXANCNFSM4KC7NF5Q .