是否可以在所选实体未引用的表上与CriteriaBuilder
进行联接?由于CriteriaBuilder.join()
希望将属性名称作为参数,因此似乎无法使用。
为了更清楚一点,原始查询如下所示:
select Vehicle v left join VehicleStatus vs on v.id = vs.vehicleId
...
Vehicle
未定义与VehicleStatus
的关系。而且目前不希望对数据库进行更改,但是如果需要的话也可以。
当前我拥有的代码
final Join<Vehicle, VehicleStatus> vs = vehicle.join("vs", JoinType.LEFT);
vs.on(cb.equal(vs.get("vehicleId"), vehicle.get("id")));
失败java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [vs] on this ManagedType
答案 0 :(得分:1)
否,您需要映射的关联才能使用<configuration>
<system.webServer>
<!-- indicates that the hello.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<!-- use URL rewriting to redirect the entire branch of the URL namespace
to hello.js node.js application; for example, the following URLs will
all be handled by hello.js:
http://localhost/node/express/myapp/foo
http://localhost/node/express/myapp/bar
-->
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
<add segment="node_modules"/>
</hiddenSegments>
</requestFiltering>
</security>
<rewrite>
<rules>
<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$"/>
</rule>
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<rule name="NodeLog">
<action type="Rewrite" url="iisnode{REQUEST_URI}"/>
</rule>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server.js"/>
</rule>
</rules>
</rewrite>
<httpErrors existingResponse="PassThrough" />
<iisnode watchedFiles="web.config;*.js;node_modules\*;client\*"/>
</system.webServer>
</configuration>
创建连接子句。
使用Hibernate,您可以在JPQL查询中join 2 unassociated entities。语法几乎与SQL相同。但这是特定于Hibernate的功能,不是JPA标准的一部分。