Results 1 to 10 of 10

Thread: UsersConnectionRepository and ConnectionRepository for JPA

  1. #1
    Join Date
    Oct 2009
    Location
    Milano
    Posts
    49

    Default UsersConnectionRepository and ConnectionRepository for JPA

    Is there any version of UsersConnectionRepository and ConnectionRepository for apps using JPA?
    2+2=5

  2. #2
    Join Date
    Oct 2009
    Location
    Milano
    Posts
    49

    Default

    I found this https://github.com/mschipperheyn/spring-social-jpa

    I'm answer my own question in case this is useful for somebody else.
    2+2=5

  3. #3
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    You know I thought about going the JPA way too. I mean besides already using Spring Data JPA for some of our data, and the rest using Spring Data other NoSQL projects, that I thought for adding Spring Social it would be nice to keep with that pattern. But after thinking about it, all you have to do for using the already built Jdbc version is run the ddl script to make that one userconnect table and that was it.

    As opposed to doing more work to get jpa. Yes that project makes it easier where you just implement their RemoteUser interface.
    Although that project hasn't been touched in a year. But there aren't many classes to have to constantly be changing it.

    So I guess almost a wash. Nevermind.

    Mark

  4. #4
    Join Date
    Oct 2009
    Location
    Milano
    Posts
    49

    Default

    interesting... thing is we're using entitymanagers and such so i don't even have a datasource hanging around.
    2+2=5

  5. #5
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    Um, yes you do have a datasource. No other way to get a connection to the database. And EntityManagerFactory which creates EntityManager's need/require a datasource.

    Now you might not be accessing the Datasource yourself directly in your config. It might be that you are running in an App Server that is doing container managed EntityManager with Factory, but that is using a DataSource, a datasource that the App Server creates because of the datasource configuration that comes in the app server, or one that someone at your company defined. If it is the app server's note that the database it is using is probably just a dev temp one and not one that should be used in production.

    And that dataSource an App Server creates is just put into the JNDI tree, just like the EntityManagerFactory was.

    But that is all if you are using an App Server.

    But no matter what there is a DataSource out there that it is using.

    Mark

  6. #6
    Join Date
    Oct 2009
    Location
    Milano
    Posts
    49

    Default

    Yes I am running in an App Server that is doing container managed EntityManager with Factory

    here's a snippet of my applicationContext-jpa.xml

    Code:
    	<context:load-time-weaver
    		weaver-class="org.springframework.instrument.classloading.glassfish.GlassFishLoadTimeWeaver" />
    
    	<bean id="pum"
    		class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
    		<property name="persistenceXmlLocations">
    			<list>
    				<value>classpath*:META-INF/persistence.xml</value>
    			</list>
    		</property>
    	</bean>
    
    	<bean id="emf"
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="persistenceUnitManager" ref="pum" />
    		<property name="persistenceUnitName" value="BLABLABLA" />
    	</bean>
    2+2=5

  7. #7
    Join Date
    Aug 2004
    Posts
    1,075

    Default

    In short: There is currently not a JPA implementation of the connection repositories, aside from some work that has been done in the community.

    And, to be honest, I struggle a bit understanding why one is necessary when the JDBC-based one will work fine. The only piece of code that cares about connections is the connection repository and therefore it's not like *you're* code will be reading/writing to the connection table. And that table has no joins with other tables. For all intents and purposes, it could be in a completely different database (although it's handy having it in the same database for DataSource-reuse purposes). So why is a JPA-specific implementation needed?
    Craig Walls
    Spring Social Project Lead

  8. #8
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    I agree that a JPA isn't needed. I am big on JPA and rarely use Jdbc. Mostly use Jdbc to test out my JPA code.

    But I choose to use the built in jdbcConnectionRepository because it was the least amount of work. Just create the table in the database.

    I can see, as Yuan did building a new implementation if you are using NoSQL and don't have an RDBMS in your application.

    Mark

  9. #9
    Join Date
    Oct 2009
    Location
    Milano
    Posts
    49

    Default

    Fine. Then I guess my issue is on getting a dataSource out of the configuration we're currently using (see my previous post)
    2+2=5

  10. #10
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    My guess is look in your persistence.xml file. Somewhere you have to connect your EntityManagerFactory to a datasource, and in this case it should show in that file.

    Or, I haven't used Glassfish, but how does it define and configure a datasource, and find that file to find the name.

    If you need it to be a bean, then you can do a jndi lookup in your configuration with

    <jee:jndi-lookup> tag.

    Mark

Tags for this Thread

Posting Permissions

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