NonUniqueDiscoveredSqlAliasException:遇到重复的SQL别名

时间:2018-09-20 16:35:01

标签: java hibernate jpa

我正在尝试测试多个构造函数结果。我收到该异常消息: org.hibernate.loader.custom.NonUniqueDiscoveredSqlAliasException:在自动发现本机SQL查询期间遇到重复的SQL别名[ID]

这是sqlresultsetmapping批注:

SqlResultSetMapping(name = RoomHktaskListWrapper.ROOMHKTASKLISTWRAPPER, classes = {
            @ConstructorResult(targetClass = RoomHktaskListWrapper.class, columns = {
                    @ColumnResult(name = "ID", type = Long.class),
                    @ColumnResult(name = "ROOMNO", type = String.class),
                    @ColumnResult(name = "ROOMTYPEID", type = Long.class),
                    @ColumnResult(name = "ROOMTYPE", type = String.class),
                    @ColumnResult(name = "ROOMTYPEDESC", type = String.class),
                    @ColumnResult(name = "TRANSDATE", type = LocalDate.class),
                    @ColumnResult(name = "FLOORID", type = Long.class),
                    @ColumnResult(name = "FLOORCODE", type = String.class),
                    @ColumnResult(name = "FLOORDESC", type = String.class),
                    @ColumnResult(name = "BLOCKID", type = Long.class),
                    @ColumnResult(name = "BLOCKCODE", type = String.class),
                    @ColumnResult(name = "BLOCKDESC", type = String.class),
                    @ColumnResult(name = "HKSCORE", type = Double.class),
                    @ColumnResult(name = "EMPID", type = Long.class),
                    @ColumnResult(name = "EMPCODE", type = String.class),
                    @ColumnResult(name = "EMPNAME", type = String.class),
                    @ColumnResult(name = "ROOMSTATE", type = String.class),
                    @ColumnResult(name = "BEDTYPEID", type = Long.class),
                    @ColumnResult(name = "BEDTYPECODE", type = String.class),
                    @ColumnResult(name = "BEDTYPEDESC", type = String.class),
                    @ColumnResult(name = "LOCID", type = Long.class),
                    @ColumnResult(name = "LOCCODE", type = String.class),
                    @ColumnResult(name = "LOCDESC", type = String.class)
            }),
            @ConstructorResult(targetClass = RoomHktaskListWrapper.class, columns = {
                    @ColumnResult(name = "ID", type = Long.class),
                    @ColumnResult(name = "ROOMNO", type = String.class),
                    @ColumnResult(name = "ROOMTYPEID", type = Long.class),
                    @ColumnResult(name = "ROOMTYPE", type = String.class),
                    @ColumnResult(name = "ROOMTYPEDESC", type = String.class),
                    @ColumnResult(name = "TRANSDATE", type = LocalDate.class),
                    @ColumnResult(name = "FLOORID", type = Long.class),
                    @ColumnResult(name = "FLOORCODE", type = String.class),
                    @ColumnResult(name = "FLOORDESC", type = String.class),
                    @ColumnResult(name = "BLOCKID", type = Long.class),
                    @ColumnResult(name = "BLOCKCODE", type = String.class),
                    @ColumnResult(name = "BLOCKDESC", type = String.class),
                    @ColumnResult(name = "HKSCORE", type = Double.class),
                    @ColumnResult(name = "EMPID", type = Long.class),
                    @ColumnResult(name = "EMPCODE", type = String.class),
                    @ColumnResult(name = "EMPNAME", type = String.class),
                    @ColumnResult(name = "ROOMSTATE", type = String.class),
                    @ColumnResult(name = "BEDTYPEID", type = Long.class),
                    @ColumnResult(name = "BEDTYPECODE", type = String.class),
                    @ColumnResult(name = "BEDTYPEDESC", type = String.class),
                    @ColumnResult(name = "LOCID", type = Long.class),
                    @ColumnResult(name = "LOCCODE", type = String.class),
                    @ColumnResult(name = "LOCDESC", type = String.class),
                    @ColumnResult(name = "GID", type = UUID.class)
            })
    })

和命名查询:

@NamedNativeQuery(name = "Room.getRoomHktaskListWrapper", query = "select * from SP_ROOM_HKTASK_LIST (:transdate, :roomtype, :roomno, :blockid, :floorid, :incassigned, :hotelrefno)", resultSetMapping = RoomHktaskListWrapper.ROOMHKTASKLISTWRAPPER)

问题是,数据库管理员可能会在存储过程中添加“ gid”字段。我正在尝试找到适合两种情况的解决方案。

0 个答案:

没有答案