“Many-to-many” example This is a many-to-many relationship table design, a STOCK table has more than one CATEGORY, and CATEGORY can belong to more than one STOCK, the relationship is linked with a third table called STOCK_CATEGORY. Hibernate implementation In Hibernate, this “many-to-many” relationship can implemented in two ways : Hibernate XML Mapping file Hibernate Annotation [...]
Archive for февруари, 2010
Cascade – JPA & Hibernate annotation common mistake
февруари 7th, 2010
admin Mistake In the one-to-many example, many developers declared the JPA cascade options as following : … @Entity @Table(name = „stock“, catalog = „mkyong“, uniqueConstraints = { @UniqueConstraint(columnNames = „STOCK_NAME“), @UniqueConstraint(columnNames = „STOCK_CODE“) }) public class Stock implements java.io.Serializable { … private Set<StockDailyRecord> stockDailyRecords = new HashSet<StockDailyRecord>(0); @OneToMany(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST,CascadeType.MERGE }, mappedBy = [...]
RSS Feed
Twitter

Posted in

