jdbi-folder icon indicating copy to clipboard operation
jdbi-folder copied to clipboard

Joining enums does not work

Open situokko opened this issue 9 years ago • 1 comments

Hi, I have been using JDBI-Folder for some time and now encountered something new when tried to join table that that has one-to-many mapping to enumerations.

Tables

  • products (id, ...)
  • items (id, fk_product_id, ...)
  • features (fk_product_id, feature) //feature is custom enum type in PostgreSql

` class Product { @PrimaryKey long id;

@OneToMany("items") List<Item> items; //Item is a class, similar to Product

@OneToMany("features") List<Feature> feature; //Feature is an enum }

interface ProductDAO { @SqlQuery(""" select p.*, i.id items$id, ... f.feature features$feature from products p left outer join items i on (p.id = i.fk_product_id) left outer join features f on (p.id = f.fk_product_id) ... """) FoldingList<Product> findProducts(...); } ` findProducts() worked ok before adding the features join there, but now it does not return them.

I did get it to work by switching Feature enum class, to this:

class FeatureHolder { //feature field in fact is not the PK but this is required to get more than 1 Feature out @PrimaryKey public Feature feature }

So wondering if it would be possible to get List of enums instead of List of enum-holding-classes?

situokko avatar Feb 17 '16 14:02 situokko

Hi, Thanks for letting us know the issue. Spend time in fixing the issue. It needs significant effort now. Will try to get it done soon. Till then you can hack way to move forward.

Manikandan-K avatar Feb 23 '16 16:02 Manikandan-K