I've just migrated from 3.2.0.rc2 to 3.2.0.ga
Everything was working in rc2.
Now i have such exception during initialization.
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.mypkg.core.dao.hibernate.persistent.OwnedUserStocks.stock in com.mypkg.core.dao.hibernate.persistent.Stock.ownedStocks
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:506)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:471)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1054)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1210)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:807)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:740)
Here's my annotations:
Code:
@Entity
@DiscriminatorValue("owned")
@Proxy(lazy = true, proxyClass = com.mypkg.core.dao.hibernate.persistent.OwnedUserStocks.class)
public class OwnedUserStocks extends UserStocks {
}
Code:
@Entity
@DiscriminatorValue("owed")
@Proxy(lazy = true, proxyClass = com.mypkg.core.dao.hibernate.persistent.OwedUserStocks.class)
public class OwedUserStocks extends UserStocks implements IOwedUserStocks {
...
}
Code:
@BatchSize(size = 20)
@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name = "stock_type",
discriminatorType = DiscriminatorType.STRING
)
@DiscriminatorValue("common")
@Table(name = "user_stocks")
public abstract class UserStocks extends AbstractIDComparable implements IUserStocks {
...
...
@ManyToOne(targetEntity = com.mypkg.core.dao.hibernate.persistent.Stock.class,
cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
@JoinColumn(name = "stock_id", nullable = false)
public IStock getStock() {
return stock;
}
...
}
Code:
@BatchSize(size = 15)
@Entity
@Table(name = "stock")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Proxy(lazy = true, proxyClass = com.mypkg.core.dao.hibernate.persistent.Stock.class)
@javax.persistence.SequenceGenerator(
name = "SEQ_STORE",
sequenceName = "stock_sequence"
)
public class Stock extends AbstractIDComparable implements IStock {
...
@OneToMany(targetEntity = com.mypkg.core.dao.hibernate.persistent.OwnedUserStocks.class, mappedBy = "stock",
cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public List<IUserStocks> getOwnedStocks() {
if (null == ownedStocks) {
ownedStocks = new ArrayList<IUserStocks>();
}
return ownedStocks;
}
@OneToMany(targetEntity = com.mypkg.core.dao.hibernate.persistent.OwedUserStocks.class, mappedBy = "stock",
cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public List<IUserStocks> getOwedStocks() {
if (null == owedStocks) {
owedStocks = new ArrayList<IUserStocks>();
}
return owedStocks;
}
}
I use Spring for Hibernate configuration and required classes are in Spring configuration. So hiberante should find all classes. And this configuration was wroking on 3.20.rc2. I've just change hibernate version in pom.xml (maven configuration file) and don't make any other changes.
Is it bug or i should make some changes ?
I look at migration guide and i don't see any issues related to my problem.