Paging and SFM

32 views
Skip to first unread message

jo...@zynde.com

unread,
Nov 20, 2017, 10:47:19 PM11/20/17
to SimpleFlatMapper
Hi

I'm looking at adding in some paging functionality to my app which is using Spring JDBCTemplate and SFM. I know there are various ways of achieving paging and I'm trying to see what works with SFM. The data passed in to SFM needs to be in a specific order from what I read about Joins. 

I guess my query is assume we have these relations below (best I could make up)

User (user_id)
  Addresses (address_id)
  Friend (friend_id)
    Addresses (friend_address_id) 

1) Can SFM handle this?
2) Do I need to order by user_id, address_id, friend_id, friend_address_id
3) If i'm paging my query might be in a different order to get the right page I assume I need to reorder the final data from the database to suit 2)

Thanks

Arnaud Roger

unread,
Nov 21, 2017, 1:34:18 AM11/21/17
to jo...@zynde.com, SimpleFlatMapper
So yes the root object row needs to 
Come in continuous block.
So if your joining and ordering on a one to one your fine, but on one to many it’s tricky


What if you user has 2 adresses and one puts him at the start of the order and the other at the end? How would you solve that? Having him in twice? 
Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "SimpleFlatMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simpleflatmapp...@googlegroups.com.
To post to this group, send email to simplefl...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/simpleflatmapper/67b9a7b1-6b28-4400-935e-aa4b1cefaa53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arnaud Roger

unread,
Nov 21, 2017, 1:53:28 AM11/21/17
to SimpleFlatMapper
I need sometime to write my thought process about that.
But ordering on the many side of a x-to-many  is always gonna be problematic.


On Tuesday, 21 November 2017 06:34:18 UTC, Arnaud Roger wrote:
So yes the root object row needs to 
Come in continuous block.
So if your joining and ordering on a one to one your fine, but on one to many it’s tricky


What if you user has 2 adresses and one puts him at the start of the order and the other at the end? How would you solve that? Having him in twice? 
Sent from my iPhone

On 21 Nov 2017, at 03:47, jo...@zynde.com wrote:

Hi

I'm looking at adding in some paging functionality to my app which is using Spring JDBCTemplate and SFM. I know there are various ways of achieving paging and I'm trying to see what works with SFM. The data passed in to SFM needs to be in a specific order from what I read about Joins. 

I guess my query is assume we have these relations below (best I could make up)

User (user_id)
  Addresses (address_id)
  Friend (friend_id)
    Addresses (friend_address_id) 

1) Can SFM handle this?
2) Do I need to order by user_id, address_id, friend_id, friend_address_id
3) If i'm paging my query might be in a different order to get the right page I assume I need to reorder the final data from the database to suit 2)

Thanks

--
You received this message because you are subscribed to the Google Groups "SimpleFlatMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simpleflatmapper+unsubscribe@googlegroups.com.
To post to this group, send email to simpleflatmapper@googlegroups.com.

John Mooney

unread,
Nov 21, 2017, 3:03:46 PM11/21/17
to Arnaud Roger, SimpleFlatMapper
Hi

I’ve not looked at the SFM code so there may be reasons why this idea doesn’t work

If you know the id columns which it appears you need to provide to SFM for processing then can’t you work out if the row part is new or should be added to?

That is probably a slower process than you have but maybe an option if you need to maintain order
On Tue, 21 Nov 2017 at 4:53 pm, Arnaud Roger <arnaud...@gmail.com> wrote:
I need sometime to write my thought process about that.
But ordering on the many side of a x-to-many  is always gonna be problematic.


On Tuesday, 21 November 2017 06:34:18 UTC, Arnaud Roger wrote:
So yes the root object row needs to 
Come in continuous block.
So if your joining and ordering on a one to one your fine, but on one to many it’s tricky


What if you user has 2 adresses and one puts him at the start of the order and the other at the end? How would you solve that? Having him in twice? 
Sent from my iPhone

On 21 Nov 2017, at 03:47, jo...@zynde.com wrote:

Hi

I'm looking at adding in some paging functionality to my app which is using Spring JDBCTemplate and SFM. I know there are various ways of achieving paging and I'm trying to see what works with SFM. The data passed in to SFM needs to be in a specific order from what I read about Joins. 

I guess my query is assume we have these relations below (best I could make up)

User (user_id)
  Addresses (address_id)
  Friend (friend_id)
    Addresses (friend_address_id) 

1) Can SFM handle this?
2) Do I need to order by user_id, address_id, friend_id, friend_address_id
3) If i'm paging my query might be in a different order to get the right page I assume I need to reorder the final data from the database to suit 2)

Thanks

--
You received this message because you are subscribed to the Google Groups "SimpleFlatMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simpleflatmapp...@googlegroups.com.
To post to this group, send email to simplefl...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "SimpleFlatMapper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/simpleflatmapper/cjAjKnSu-As/unsubscribe.
To unsubscribe from this group and all its topics, send an email to simpleflatmapp...@googlegroups.com.
To post to this group, send email to simplefl...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/simpleflatmapper/3b520990-a158-49b0-a857-dd61adc42b5c%40googlegroups.com.

Arnaud Roger

unread,
Nov 21, 2017, 3:34:29 PM11/21/17
to SimpleFlatMapper
if you order on a one to many column

user_id, address_id
1, 1
2, 1
1, 2

what is the right way to return does data if you root object is user?

1 -
1, {1, 2}
2, {2} ?

or
2 -  the current sfm return
1, {1}
2, {1}
1, {2}

or
3 -
1, {1, 2}
2, {1}
1, {1, 2}

the problem by sorting on the non root object is that there is no really any right solution. The only stable way is to switch the root object and instead of having user { adresses} to do address {users }
but that's a lot of coding.
I faced that problem recently and we just filter on one to many, no ordering.
To unsubscribe from this group and stop receiving emails from it, send an email to simpleflatmapper+unsubscribe@googlegroups.com.
To post to this group, send email to simpleflatmapper@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "SimpleFlatMapper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/simpleflatmapper/cjAjKnSu-As/unsubscribe.
To unsubscribe from this group and all its topics, send an email to simpleflatmapper+unsubscribe@googlegroups.com.
To post to this group, send email to simpleflatmapper@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages