Results 1 to 6 of 6

Thread: Persisting connections using Hibernate

  1. #1
    Join Date
    Aug 2011
    Posts
    8

    Default Persisting connections using Hibernate

    Hi again, folks.

    I'm building an app accessing facebook initially but others in the future where i need to persist the connections indefinitely. I"m somewhat new to spring and spring social, so before i go too far, i want to make sure i'm taking the right basic approach.

    i'm going to have a person table (1 row per user with connections) and a connection table (one row per connection per person). These will correspond to connectionrepository and connection classes. the core of it is i'll be saving the ConnectionData in the connection table and then grabbing it out of there when i need to utlize that connection later to post to the person's feed.

    so i'm building implementations of usersconnectionrepository, connectionrepository and connection. does this sound like the right direction?

    if so, i have a general question regarding some of the abstract methods i have to implement...

    for Connection, there seem to be many that require some interface with the provider (e.g. facebook) - like getApi, sync, refresh, hasExpired, etc. i would have thought these would not be abstract.

    what am i missing? where do i go to find implementations of these? is there another class i can extend or something that would provide these methods? What i see in the reference docs are Oauth1Connection and Oauth2Connection. but i'm not sure i should extend one of these, as i'd like my connection class to be independent of those particulars.

    i hope this makes sense. sorry if it's a dumb question.

    thanks so much for you all's very timely responses to my other questions thus far.

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    I would first make sure the existing JdbcUsersConnectionRepository implementation is not suitable for you. Will save you a lot of work.

    Assuming you actually need your own repository implementation, I would study how the existing implementation works. Notice how the Connection instances are created by ConnectionFactories obtained from a ConnectionFactoryLocator - they are in no way coupled to the repository layer.

    In summary, you should not have to create a custom Connection implementation just to change the strategy for how connections are persisted. I would expect you to have to create a new UsersConnectionRepository implementation and that's it (internally it will need to define a single-user ConnectionRepository implementation type of course).

    Keith
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    Aug 2011
    Posts
    8

    Default

    thanks, Keith.

    i certainly don't want to reinvent any wheels. one additional question... where do i go to look at the gory details of the implementation? i guess i need to download the spring social source code? and where would i find the .sql file referred to in the reference doc that has the table definitions for connection persistence?

    Ben

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Review the source on github - either by cloning the repository or reviewing on-line. The code isn't gory, it's art man.

    Keith
    Keith Donald
    Core Spring Development Team

  5. #5
    Join Date
    Jan 2008
    Posts
    248

  6. #6

    Default

    Hi,
    From my point of view you should use JdbcTemplate or HibernateTemplate as a beginner.

    spring framework
    Last edited by abani; Dec 18th, 2011 at 01:23 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •