-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Many-To-One joins dont seem to work
PostPosted: Fri Aug 12, 2016 3:19 am 
Newbie

Joined: Fri Aug 12, 2016 2:54 am
Posts: 1
In the official documentation it says that *-To-One joins in queries should work, but i get weird exceptions (i use HQL). Can somebody confirm if they work or not.

I got a class SysUserGroup that in it has a SysUser class, so when i try to execute:
Code:
Select user FROM SysUserGroup ug INNER JOIN ug.sysUser user

i get this exception:
Code:
java.util.NoSuchElementException
   at java.util.ArrayList$Itr.next(Unknown Source)
   at org.hibernate.ogm.query.parsing.impl.ParserPropertyHelper.getColumn(ParserPropertyHelper.java:227)
   at org.hibernate.ogm.datastore.mongodb.query.parsing.impl.MongoDBPropertyHelper.getColumnName(MongoDBPropertyHelper.java:45)
   at org.hibernate.ogm.datastore.mongodb.query.parsing.impl.MongoDBPropertyHelper.getColumnName(MongoDBPropertyHelper.java:36)
   at org.hibernate.ogm.datastore.mongodb.query.parsing.impl.MongoDBQueryRendererDelegate.setPropertyPath(MongoDBQueryRendererDelegate.java:69)
   at org.hibernate.hql.ast.render.QueryRenderer.valueExpressionPrimary(QueryRenderer.java:7591)
   at org.hibernate.hql.ast.render.QueryRenderer.valueExpression(QueryRenderer.java:7113)
   at org.hibernate.hql.ast.render.QueryRenderer.rootSelectExpression(QueryRenderer.java:4300)
   at org.hibernate.hql.ast.render.QueryRenderer.rootSelectExpression(QueryRenderer.java:4175)
   at org.hibernate.hql.ast.render.QueryRenderer.rootSelectExpression(QueryRenderer.java:4124)
   at org.hibernate.hql.ast.render.QueryRenderer.selectClause(QueryRenderer.java:3913)
   at org.hibernate.hql.ast.render.QueryRenderer.selectFrom(QueryRenderer.java:2713)
   at org.hibernate.hql.ast.render.QueryRenderer.querySpec(QueryRenderer.java:2181)
   at org.hibernate.hql.ast.render.QueryRenderer.queryExpression(QueryRenderer.java:2105)
   at org.hibernate.hql.ast.render.QueryRenderer.queryStatement(QueryRenderer.java:1744)
   at org.hibernate.hql.ast.render.QueryRenderer.queryStatementSet(QueryRenderer.java:1657)
   at org.hibernate.hql.ast.render.QueryRenderer.statement(QueryRenderer.java:653)
   at org.hibernate.hql.ast.spi.QueryRendererProcessor.process(QueryRendererProcessor.java:51)
   at org.hibernate.hql.QueryParser.parseQuery(QueryParser.java:82)
   at org.hibernate.ogm.datastore.mongodb.query.parsing.impl.MongoDBBasedQueryParserService.parseQuery(MongoDBBasedQueryParserService.java:40)
   at org.hibernate.ogm.query.impl.OgmQueryTranslator.getQuery(OgmQueryTranslator.java:169)
   at org.hibernate.ogm.query.impl.OgmQueryTranslator.getLoader(OgmQueryTranslator.java:134)
   at org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:128)
   at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
   at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1326)
   at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
   at edu.upc.masterthesis.demo.CustomerTest.loadUserAndRoles(CustomerTest.java:365)

and when i try to execute this:
Code:
Select user.firstname, user.lastname FROM SysUserGroup ug INNER JOIN ug.sysUser user

i get this:
Code:
java.lang.UnsupportedOperationException: Selecting associated properties not yet implemented.
   at org.hibernate.ogm.datastore.mongodb.query.parsing.impl.MongoDBQueryRendererDelegate.setPropertyPath(MongoDBQueryRendererDelegate.java:88)
   at org.hibernate.hql.ast.render.QueryRenderer.valueExpressionPrimary(QueryRenderer.java:7591)
   at org.hibernate.hql.ast.render.QueryRenderer.valueExpression(QueryRenderer.java:7113)
   at org.hibernate.hql.ast.render.QueryRenderer.rootSelectExpression(QueryRenderer.java:4300)
   at org.hibernate.hql.ast.render.QueryRenderer.rootSelectExpression(QueryRenderer.java:4175)
   at org.hibernate.hql.ast.render.QueryRenderer.rootSelectExpression(QueryRenderer.java:4124)
   at org.hibernate.hql.ast.render.QueryRenderer.selectClause(QueryRenderer.java:3913)
   at org.hibernate.hql.ast.render.QueryRenderer.selectFrom(QueryRenderer.java:2713)
   at org.hibernate.hql.ast.render.QueryRenderer.querySpec(QueryRenderer.java:2181)
   at org.hibernate.hql.ast.render.QueryRenderer.queryExpression(QueryRenderer.java:2105)
   at org.hibernate.hql.ast.render.QueryRenderer.queryStatement(QueryRenderer.java:1744)
   at org.hibernate.hql.ast.render.QueryRenderer.queryStatementSet(QueryRenderer.java:1657)
   at org.hibernate.hql.ast.render.QueryRenderer.statement(QueryRenderer.java:653)
   at org.hibernate.hql.ast.spi.QueryRendererProcessor.process(QueryRendererProcessor.java:51)
   at org.hibernate.hql.QueryParser.parseQuery(QueryParser.java:82)
   at org.hibernate.ogm.datastore.mongodb.query.parsing.impl.MongoDBBasedQueryParserService.parseQuery(MongoDBBasedQueryParserService.java:40)
   at org.hibernate.ogm.query.impl.OgmQueryTranslator.getQuery(OgmQueryTranslator.java:169)
   at org.hibernate.ogm.query.impl.OgmQueryTranslator.getLoader(OgmQueryTranslator.java:134)
   at org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:128)
   at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
   at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1326)
   at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
   at edu.upc.masterthesis.demo.CustomerTest.loadUserAndRoles(CustomerTest.java:365)


This is my POM.xml:
Code:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.hibernate.ogm.demos</groupId>
    <artifactId>nosql-with-hibernate-ogm-101-part-1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>NoSQL with Hibernate OGM 101 - Part 1</name>
    <description>Demonstrates how to persist and load some entities</description>
    <url>http://hibernate.org/ogm/</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <ogm.version>5.0.1.Final</ogm.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.hibernate.ogm</groupId>
                <artifactId>hibernate-ogm-bom</artifactId>
                <type>pom</type>
                <version>${ogm.version}</version>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- Use this for MongoDB -->
        <dependency>
            <groupId>org.hibernate.ogm</groupId>
            <artifactId>hibernate-ogm-mongodb</artifactId>
        </dependency>
       
       
        <dependency>
            <groupId>org.jboss.jbossts</groupId>
            <artifactId>jbossjta</artifactId>
            <version>4.16.6.Final</version>
        </dependency>
       
       
      <!-- Search -->
      <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-search</artifactId>
             <version>5.5.4.Final</version>
      </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-assert</artifactId>
            <version>1.4</version>
            <scope>test</scope>
        </dependency>
               
      <dependency>
          <groupId>commons-io</groupId>
          <artifactId>commons-io</artifactId>
          <version>2.4</version>
      </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

and i build my SessionFactory like this:
Code:
public SessionFactory createSessionFactory(){
      SysConnection sysConnection = new SysConnection("MongoDBTest", "nosql", "localhost", "27017", null, null, null, null);
      sysConnection.setDataStore("mongodb");
      sysConnection.setDatabaseName("airCRMDB");
      
      OgmConfiguration configuration = new OgmConfiguration();

      // "org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider"
      configuration.setProperty("hibernate.ogm.datastore.provider", sysConnection.getDataStore());
      configuration.setProperty("hibernate.ogm.datastore.database", sysConnection.getDatabaseName());
      configuration.setProperty("hibernate.ogm.datastore.host", sysConnection.getHost());
      
      configuration.setProperty("hibernate.transaction.coordinator_class", "jta");
      
      configuration.addAnnotatedClass(SysUser.class);
      configuration.addAnnotatedClass(SysGroup.class);
      configuration.addAnnotatedClass(SysUserGroup.class);
      configuration.addAnnotatedClass(SysRight.class);
      
      ServiceRegistry serviceRegistry;
      SessionFactory sessionFactory;
      
      serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
      sessionFactory = configuration.buildSessionFactory(serviceRegistry);
      
      return sessionFactory;
   }


Top
 Profile  
 
 Post subject: Re: Many-To-One joins dont seem to work
PostPosted: Fri Nov 11, 2016 8:41 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Sorry for the late reply.
join on entities won't work, only join on embedded collection are supported


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.