title: How to create subquery in Querydsl
body: <p>I am new to Querydsl. I have to convert following query into Querydsl. I tried like below but I am not getting result.</p>
  
  <p>Can any one please tell me what I am missing or any thing doing wrong in query?</p>
  
  <pre><code>select * from room  as room 
        where room.nroom_id not in(
                            select rdm.nroom_id from roomdepartmentmapping as rdm)
  </code></pre>
  
  <p>I tried like this</p>
  
  <pre><code>    JPAQuery&lt;Tuple&gt; query = new JPAQuery&lt;Tuple&gt;(em);  
  
      query.from(room) 
           .where(room.nRoomId.notIn
                           (query.select(roomDepartmentMapping.nRoomId)
                                 .from(roomDepartmentMapping)
                           )
                 );
  </code></pre>
  
  <p><strong>Console</strong></p>
  
  <pre><code>   at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:31) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.core.types.OperationImpl.accept(OperationImpl.java:83) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.core.support.SerializerBase.handle(SerializerBase.java:92) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.jpa.JPQLSerializer.serialize(JPQLSerializer.java:220) ~[querydsl-jpa-4.1.4.jar:na]
          at com.querydsl.jpa.JPQLSerializer.visit(JPQLSerializer.java:358) ~[querydsl-jpa-4.1.4.jar:na]
          at com.querydsl.jpa.JPQLSerializer.visit(JPQLSerializer.java:39) ~[querydsl-jpa-4.1.4.jar:na]
          at com.querydsl.core.types.SubQueryExpressionImpl.accept(SubQueryExpressionImpl.java:57) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.core.support.SerializerBase.handle(SerializerBase.java:92) ~[querydsl-core-4.1.4.jar:na]            
          at com.querydsl.jpa.JPQLSerializer.visitOperation(JPQLSerializer.java:403) ~[querydsl-jpa-4.1.4.jar:na]
          at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:231) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:31) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.core.types.OperationImpl.accept(OperationImpl.java:83) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.core.support.SerializerBase.handle(SerializerBase.java:92) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.jpa.JPQLSerializer.serialize(JPQLSerializer.java:220) ~[querydsl-jpa-4.1.4.jar:na]
          at com.querydsl.jpa.JPQLSerializer.visit(JPQLSerializer.java:358) ~[querydsl-jpa-4.1.4.jar:na]
          at com.querydsl.jpa.JPQLSerializer.visit(JPQLSerializer.java:39) ~[querydsl-jpa-4.1.4.jar:na]
          at com.querydsl.core.types.SubQueryExpressionImpl.accept(SubQueryExpressionImpl.java:57) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.core.support.SerializerBase.handle(SerializerBase.java:92) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.core.support.SerializerBase.visitOperation(SerializerBase.java:270) ~[querydsl-core-4.1.4.jar:na]
          at com.querydsl.jpa.JPQLSerializer.visitOperation(JPQLSerializer.java:403) ~[querydsl-jpa-4.1.4.jar:na]
          at com.querydsl.core.support.SerializerBase.visit(SerializerBase.java:231) ~[querydsl-core-4.1.4.jar:na]           
          at com.querydsl.jpa.JPQLSerializer.visit(JPQLSerializer.java:39) ~[querydsl-jpa-4.1.4.jar:na]
          at com.querydsl.core.types.SubQueryExpressionImpl.accept(SubQueryExpressionImpl.java:57) ~[querydsl-core-4.1.4.jar:na]
  </code></pre>