0

我是休眠新手并尝试运行应用程序,但在运行应用程序时遇到问题。我得到以下错误,

org.hibernate.MappingException: Unknown entity: DELETE com.on.transport.dto.updated.RoutePlaceMappingUpdated rpmu where rpmu.route.routeId=?


@Entity
@Table(name = "route_place_mapping")
public class RoutePlaceMappingUpdated {

@Id @GeneratedValue
@Column(name = "route_place_mapping_id")
private Long routePlaceMappingId;

@OneToOne(targetEntity=RouteUpdated.class)
@JoinColumn(name="route_id")
private RouteUpdated route;

@OneToOne(targetEntity=PlaceUpdated.class)
@JoinColumn(name="place_id")
private PlaceUpdated place;


@Temporal(TemporalType.TIMESTAMP)
@Column(name = "arrival_time", nullable=false, length=19)
private Date arrivalTime;

@Column(name = "sequence_of_arrival")
private String sequenceArrivalAtPlace;

//getter - setter
}


@Entity
@Table(name = "route")
public class RouteUpdated {

    @Id @GeneratedValue
    @Column(name = "route_id")
    private Long routeId;

    @Column(name = "route_name")
    private String routeName;

//getter-setter
}


@Entity
@Table(name = "place")
public class PlaceUpdated {


    @Id @GeneratedValue
    @Column(name = "place_id")
    private Long placeId;

    @Column(name = "place_name")
    private String placeName;   

//getter-setter
}

我正在调用以下函数,但出现错误。

@Override
public boolean deleteAllInBetweenPlaceOfRouteByRouteId(Long routeId){
    String hql1 = "DELETE com.on.transport.dto.updated.RoutePlaceMappingUpdated rpmu where rpmu.route.routeId=?";
    Object[] queryParam = {routeId};
    getHibernateTemplate().delete(hql1, queryParam);
    return true;
}

表结构

route
---------------
route_id int
route_name varchar


place
---------------
place_id int
place_name varchar


route_place_mapping
----------------------
route_place_mapping_id   int
route_id int
place_id int

我在路线和地点属性的 RoutePlaceMappingUpdated 类中遗漏了一些东西,但我无法弄清楚。

4

1 回答 1

0

您正在超越异常,因为休眠将 DELETE 视为一个实体并试图找到它,但显然无法找到它。

于 2013-07-04T19:12:10.830 回答