Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Hibernate configuration for one-to-many relations

    Hi,

    I am having an issue with the configuration for one-to-many relationships.

    At JPADS.html I am entering the following:

    <script src="JPADS_js/sc/DataSourceLoader?dataSource=conexionListValue,conexionValueList"></script>

    Which is supposed to load the datasources I need. However, these datasources are connected by a one-to-many relationship and I am getting the following traceback:

    0] DEBUG DataSourceAnnotations - Generating data source 'ListValue' for class bean.hb.ListValue
    === 2012-12-19 12:07:45,484 [58-0] DEBUG DataSourceAnnotations - Generating data source 'Object' for class java.lang.Object
    === 2012-12-19 12:07:45,515 [58-0] DEBUG DataSourceAnnotations - Fields are annotated.
    === 2012-12-19 12:07:45,515 [58-0] DEBUG DataSourceAnnotations - Generating field 'serialVersionUID' of type long
    === 2012-12-19 12:07:45,515 [58-0] DEBUG DataSourceAnnotations - Skipping.
    === 2012-12-19 12:07:45,515 [58-0] DEBUG DataSourceAnnotations - Generating field 'id' of type java.lang.Long
    === 2012-12-19 12:07:45,531 [58-0] DEBUG DataSourceAnnotations - Field configuration generated: {primaryKey=true, name=id, length=255, canEdit=true, required=true, type=integer}
    === 2012-12-19 12:07:45,531 [58-0] DEBUG DataSourceAnnotations - Generating field 'description' of type java.lang.String
    === 2012-12-19 12:07:45,531 [58-0] DEBUG DataSourceAnnotations - Field configuration generated: {name=description, length=128, canEdit=true, required=false, type=text}
    === 2012-12-19 12:07:45,531 [58-0] DEBUG DataSourceAnnotations - Generating field 'name' of type java.lang.String
    === 2012-12-19 12:07:45,531 [58-0] DEBUG DataSourceAnnotations - Field configuration generated: {name=name, length=128, canEdit=true, required=false, type=text}
    === 2012-12-19 12:07:45,531 [58-0] DEBUG DataSourceAnnotations - Generating field 'value' of type java.lang.Integer
    === 2012-12-19 12:07:45,531 [58-0] DEBUG DataSourceAnnotations - Field configuration generated: {name=value, type=integer}
    === 2012-12-19 12:07:45,531 [58-0] DEBUG DataSourceAnnotations - Generating field 'valueList' of type bean.hb.ValueList
    === 2012-12-19 12:07:45,546 [58-0] DEBUG DataSourceAnnotations - Field configuration generated: {name=valueList, type=any}
    === 2012-12-19 12:07:46,062 [58-0] ERROR DataSourceLoader - Exception while attempting to load a DataSource
    org.hibernate.AnnotationException: @OneToOne or @ManyToOne on bean.hb.ListValue.valueList references an unknown entity: bean.hb.ValueList
    at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:109)
    at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1521)
    at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1446)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1351)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1733)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1784)
    at com.isomorphic.hibernate.HibernateDataSource.init(HibernateDataSource.java:411)
    at com.isomorphic.datasource.DataSource.initialize(DataSource.java:400)
    at com.isomorphic.dataso
    ...

    I understand that the problem is that the datasource ListValue references a datasource, ValueList, that has not been processed yet. However, a similar issue happens if I let it process ValueList datasource first. Is there any way to declare datasource references before these are processed?

    It seems to me that there should be an obvious solution for this problem as most users of Hibernate Datasource have interconnected tables. However, I cannot find it. Could you please help?

    Regards,
    Last edited by panizo; 19 Dec 2012, 04:46.

    #2
    That's not us throwing an Exception, it's Hibernate. It suggests your configuration is broken in some way; perhaps you've registered entities in two different Hibernate configurations, which would mean they couldn't reference one another.

    Comment


      #3
      Thank you for your response, Isomorphic.

      That is right, it is a hibernate exception. Only, we are working with hibernate in other parts of the project and they do not show any problems. In fact, we have been able to setup a Hibernate datasource connection to an isolated table, but never to interconnected tables.

      We are seriously considering using SmartGWT EE for UI design in our project. However, a Hibernate datasource is key to this decision and we need to make sure it works.

      Do you happen to have a project that uses a SmartGWT Hibernate Datasource and connects to a Google Cloud SQL database with multiple interconnected tables in Google App Engine ? If so, could you share it so we know how to set a proper configuration?

      Regards,

      Comment


        #4
        Next time mention Google GAE / Cloud SQL up front, that's a big hint.

        As far as we can tell, the special GAE environment breaks the normal functioning of Hibernate in this case. All we're calling is buildSessionFactory - we're not even trying to access annotations or relations yet, and something in the GAE environment seems to be causing Hibernate to blow up.

        Our recommendation is always to use SQLDataSource rather than Hibernate unless you have no choice. Having found one Hibernate issue on GAE already, it seems like a bad idea to keep on in your current direction.

        Comment


          #5
          Well, now that we are using an SQL connection, we are having a hard time in configuring a SQL datasource that connects to Google Cloud SQL.

          It would be very useful to have a sample project of a SmartGWT application that connects to a Google Cloud SQL database, IT WOULD BE BEST IF IT DID NOT USE GOOGLE APP ENGINE ON THE SERVER as it creates conflicts in the JSF configuration and in writing server.properties file from the Admin Console. The default GWT Jetty server should be used instead.

          @Isomorphic, do you think you could share a sample project like that? I am sure many people would benefit of such.

          However, any other projects that do connect to GSQL from a GAE server would be useful too.

          Regards,

          Comment


            #6
            There's no need for a sample project, as it would be exactly the same as the existing builtinDS sample project except settings in server.properties, where you just need to use what Google already documents.

            See this thread and note in post #12 a workaround for a Google JDBC driver issue.

            Comment


              #7
              Thank you so much, I finally get all the pieces to work, but I have one final Issue.

              Here's my server properties configuration.

              sql.devtaksee.driver.databaseName: MyDATABASE
              sql.devtaksee.database.type: mysql
              sql.devtaksee.driver.context:
              sql.devtaksee.driver.portNumber: 3306 //here is the issue
              sql.devtaksee.driver.networkProtocol: tcp
              sql.devtaksee.driver: com.google.appengine.api.rdbms.AppEngineDriver
              sql.devtaksee.driver.serverName: MYINSTANCE
              sql.devtaksee.interface.type: driverManager
              sql.devtaksee.driver.user: root
              sql.devtaksee.interface.credentialsInURL: true
              sql.devtaksee.driver.driverName: google:rdbms
              sql.devtaksee.autoJoinTransactions: true
              sql.devtaksee.database.brokenCursorAPIs: true

              This configuration works in the GAE local environment. However, it does not When I upload my application in the Google App Engine Infrastructure.

              Here is the log when connecting my LiveGrid with the Google CloudSQL.
              Invalid instance name: 'MYINSTANCE:3306'

              I know that this is not a problem in the Grid. Normally, I can connect with the database (via command line, for instance) if I don't type the ':' and the portName. So If i don't specify a portNumber, the error still persists:

              Invalid instance name: 'MYINSTANCE:'

              The ':' are making the trouble here.

              Do you think there is an easy way to configure the server.properties so the configuration does not concatenate the ':' and the portNumber?

              Comment


                #8
                Yes, see the other thread again - you can specify the complete JDBC URL instead of having us assemble it from different properties.

                Comment

                Working...
                X