Ignoring columns?

72 views
Skip to first unread message

ch.zw...@gmail.com

unread,
Mar 19, 2019, 5:37:17 PM3/19/19
to SimpleFlatMapper
Is it possible to configure sfm to ignore specific columns that are part of a resultset?

Use cases are the following:
* A list of enums are mapped from two tables A, B, where the IDs are UUIDs as strings

    +------------+
    v            |
+----+-----+   +-----------+---------+
| ID | ... |   | SOURCE_ID | ORDINAL |
+----+-----+   +-----------+---------+

In my POJO, this will be mapped to e.g.

class A {
  private List<B> bees;
}

In the select statement, table B's columns will be aliased to BEES_SOURCE_ID and BEES_ORDINAL (because in reality the same table is joined multiple times for different fields of A)

Selecting from all values from these tables will lead to an exception because sfm tries to create an enum instance from the ID string. I can work around this by a fieldMapperErrorHandler that ignores an error for this column, which effectively ignores it. But of course it would be nicer (and very likely more efficient) to be able to ignore the column in the first place.

* A list of strings are mapped from two tables A, B that look the same as the above - except that instead of ORDINAL we have VALUE, which is of a string type

The according POJO might be

class A {
  private List<String> bees;
}

Now here I have the problem that both BEES_SOURCE_ID and BEES_VALUE are added to the list of strings even though I only want BEES_VALUE to be added.

Unfortunately, I haven't found any way to tell sfm to ignore certain columns. Can that be done? If not, what would be the right configuration of a mapper to achieve what I need (without changing the SQL query)?

Thank you for any hints!

arnaud...@gmail.com

unread,
May 4, 2019, 7:42:25 AM5/4/19
to SimpleFlatMapper
that will ignore any property that can be map or add

IgnoreProperty


mapperFactory,addColumnProperty("my_column", new IgnoreProperty());

sorry for responding so late I can't remember I replied outside the group or not and just seen the unread message

Reply all
Reply to author
Forward
0 new messages