我想加入表,但这是显示错误消息

来源:爱站网时间:2021-09-16编辑:网友分享
所以这是错误消息,测试运行:1,失败:0,错误:1,跳过:0,经过的时间:2.823 s <<

问题描述


所以这是错误消息

测试运行:1,失败:0,错误:1,跳过:0,经过的时间:2.823 s

这是我的代码,所以我想加入基于customer_id的OrderTransaction列

这是我的orderRepository

    public interface CustomerRepository extends JpaRepository  {
        @Modifying
        @Query(value ="SELECT ordertransactions.id, Customer.name" +
    "FROM ordertransactions" +
    "INNER JOIN Customer ON orderransactions.id = customer.id;" ,nativeQuery = true)
        int deleteCustomer(Customer Customer); 

    //    @Query(value="select c from customer where c.name=:nama_customer")
    //    Customer findCustomerByName(@Param("namaCustomer")String nama);
        @Query(value="SELECT name, city FROM Customer")
        Customer findCustomerByName(@Param("nameCustomer")String name);
}

这是我的customerModel

@Entity
 @Table(name= "Customer")
// @EntityListeners(AuditingEntityListener.class)
public class Customer {

//
    public Customer(Long customer_id, String Name, Integer Phone , String stock , String city) {
        this.customer_id = customer_id;
        this.Name = Name;
        this.Phone = Phone;
        this.stock = stock;
        this.city = city;
    }

    public Long getCustomer_id() {
        return customer_id;
    }

    public void setCustomer_id(Long customer_id) {
        this.customer_id = customer_id;
    }

    public Customer() {
    }

//    public Customer(String string) {
//        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
//    }

//    public Customer(Long orderId, Long id, String name, Integer phone, String stock, String city) {
//        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
//    }



    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public Integer getPhone() {
        return Phone;
    }

    public void setPhone(Integer Phone) {
        this.Phone = Phone;
    }

    public String getStock() {
        return stock;
    }

    public void setStock(String stock) {
        this.stock = stock;
    }


    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }
     @Id
     @GeneratedValue(strategy=GenerationType.IDENTITY)
     private Long customer_id;

     @Column(name="name",nullable=false)
     private String Name;

     @Column(name="phone",nullable=false)
     private Integer Phone;


     @Column(name="stock",nullable=false)
     private String stock;

     @Column(name="city",nullable=false)
     private String city;


}

这是我的orderTransaction模型

@Entity
@Table(name= "ordertransactions")
public class OrderTransaction {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @Column(name="order_name",nullable = false)
    private String OrderName;

    @OneToMany
     @JoinColumn(name = "customer_id", referencedColumnName = "id", updatable = true,nullable = false)
//     @JoinColumn(name = "id", referencedColumnName = "id", updatable = true,nullable = false)
     private Customer customer;


    public OrderTransaction(Long id, String OrderName) {
        this.id = id;
        this.OrderName = OrderName;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getOrderName() {
        return OrderName;
    }

    public void setOrderName(String OrderName) {
        this.OrderName = OrderName;
    }


}

思路:


似乎您在类路径中缺少“ hibernate-core-5.x.jar”。

上一篇:xml文件中的一个列表视图和Android中java文件中的两个arraylist列表

下一篇:如何在for循环中为空字符串添加值?

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载