bahar veri sorguda insanceof nesne alırım ben de Item
sahip bir Inventory
sınıf var Item
Nasıl Bir <code>Item</code> sınıf</p> <pre><code>@Getter @Setter @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class Item { @Id private Long id; private String name; } </code></pre> <p>Ve bu iki sonraki sınıf var
@Getter
@Setter
@Entity
public class RawMaterial extends Item {
private String supplier;
}
@Getter
@Setter
@Entity
public class Product extends Item {
private BigDecimal salePrice;
}
alt sınıfı olan alan adı olarak
@Getter
@Setter
@Entity
public class Inventory {
@Id
private Long id;
@ManyToOne
private Item item;
}
Benim sorumitem
alanının örneğini nasıl alırım. dtype
ile yapılacak bir şey var mı?
public interface InventoryDao extends JpaRepository<Inventory,Long> {
@Query("FROM Inventory WHERE item instance of ?1")
public List<Inventory> getInventoryByItem(Class klazz);
}
benim öz tarafından münhal
List<Inventory> list = getInventoryByItem(Product.class);
http://stackoverflow.com/questions/2093025/how-to-perform-a-non-polymorphic-hql-query-in-hibernate belki –
Teşekkür .. ben bunu deneyecek :) – Mirza
Yani Neden beton sınıfı başına bir repo kullanmıyorsunuz? –