简体   繁体   中英

@Transient in spring data doesn't work

I have Settlement entity

@Entity
@Table(name = "settlement")
public class Settlement {

    @ManyToOne
    @JoinColumn(name = "subscription_x_product_id")
    private ProductSubscription productSubscription;

which related to ProductSubscription entity

@Entity
@Table(name = "subscriptionproduct")
public class ProductSubscription {
    @ManyToOne
    @JoinColumn(name = "product_id")
    private Product product;

which related to Product entity

@Entity
public class Product {
    @Transient
    private String enabled;

in Product entity i have field enabled which annotated with @org.springframework.data.annotation.Transient . also I have Repository

public interface SettlementRepository extends JpaRepository<Settlement, Integer>

when I call SettlementRepository.findAll(); it give exception Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'enabled'.

How can I ignore the enabled field from being loaded from the DB ?

我找到了解决方案,问题出在Annotation @org.springframework.data.annotation.Transient一旦我改为@javax.persistence.Transient它运行正常。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM