Closed arnaudroger closed 7 years ago
I have two tables as part of a join.
resource_id | privilege_id |
---|---|
1 | 10 |
2 | 10 |
3 | 11 |
id | name |
---|---|
10 | write |
11 | read |
With a select like:
select
privilege.id, privilege.name, resource_privileges.resource_id
from
privilege
join resource_privileges on resource_privileges.privilege_id = privilege.id
order by resource_privileges.resource_id
I then have mapper code like that only worked once I added "elt_0" and aliased resource_privileges.resource_id
to "elt_0".
JdbcMapper<Tuple2<Integer, List<Privilege>>> privilegeMapper = JdbcMapperFactory.newInstance()
.addKeys("id")
.addKeys("elt_0")
.newMapper(new TypeReference<Tuple2<Integer, List<Privilege>>>() { });
Thanks will check that in a week
Sent from my iPhone
On 30 Jun 2017, at 21:53, John Leacox notifications@github.com wrote:
I have two tables as part of a join.
ResourcePrivilege Join Table:
resource_id privilege_id 1 10 2 10 3 11 Privilege Table:
id name 10 write 11 read With a select like:
select privilege.id, privilege.name, resource_privileges.resource_id from privilege join resource_privileges on resource_privileges.privilege_id = privilege.id order by resource_privileges.resource_id I then have mapper code like that only worked once I added "elt_0" and aliased resource_privileges.resource_id to "elt_0".
JdbcMapper<Tuple2<Integer, List
>> privilegeMapper = JdbcMapperFactory.newInstance() .addKeys("id") .addKeys("elt_0") .newMapper(new TypeReference<Tuple2<Integer, List >>() { }); — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
I suspect Privilege is { int id; } ?
Yeah Privilege is basically an id and name:
class Privilege {
public int id;
public String name;
}
so when the field is no renamed elt0 then it ends up at element1[0].id and privilege_id is mapped to element1[1].id because it matches against the "id" prop name. Also, I discover a bug in my test I only got one privilege for 10 because there is a bug that disables the append for that list #451
I'll see if I can make the integer field take precedence over the partial match for the first column.
could you try with version 3.13rc1 that should work now.
tested with query
and mapper
and it worked
got 2 Tuple2 with id set to 1 and 2. using jool tuples and sfm-tuples