我试图使用带@ConstructorResult的@SqlResultSetMapping将Native查询的结果映射到POJO.这是我的代码:
@SqlResultSetMapping(name="foo",
classes = {
@ConstructorResult(
targetClass = Bar.class,
columns = {
@ColumnResult(name = "barId", type = Long.class),
@ColumnResult(name = "barName", type = String.class),
@ColumnResult(name = "barTotal", type = Long.class)
})
})
public class Bar {
private Long barId;
private String barName;
private Long barTotal;
...
Run Code Online (Sandbox Code Playgroud)
然后在我的DAO中:
Query query = em.createNativeQueryBar(QUERY, "foo");
... set some parameters ...
List<Bar> list = (List<Bar>) query.getResultList();
Run Code Online (Sandbox Code Playgroud)
我已经读过这个功能仅在JPA 2.1中受支持,但这正是我正在使用的.这是我的依赖:
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我发现了一些资源,包括这一个:jpa 2.1中的@ConstructorResult映射.但我仍然没有运气.
我错过了什么?为什么不能找到SqlResultSetMapping?
javax.persistence.PersistenceException: org.hibernate.MappingException: Unknown SqlResultSetMapping [foo]
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用我正在我的机器上运行的Cloud Foundry实例来使用spring cloud应用程序.我试图推送应用程序,我收到此消息:
无法找到服务postgres-service绑定到hello-spring-cloud
所以我开始追踪postgres服务.当我运行cf marketplace时,我明白了
service plans description mongodb default MongoDB NoSQL database postgresql default PostgreSQL database rabbitmq default RabbitMQ message queue redis default Redis key-value store
我尝试创建postgresql服务的服务实例,我得到:
cf create-service postgresql default postgresql-service Creating service instance postgresql-service in org xyz / space development as admin... FAILED Server error, status code: 500, error code: 10001, message: Service broker error: Not authorized
我尝试过运行,cf create-service-auth-token postgresql core 123但似乎没有帮助"未授权"消息.
我对Cloud Foundry很新,所以我有点失落.如何让我的示例应用程序绑定到postgresql服务?
更新
以下是空间的权限:
Getting users in org xyz / …