I\'m quite new to Hibernate and have been trying to determine what it will do for you and what it requires you to do.
A big one is dealing with an object that has
You have to look at cascading operations; this type of operation permits you to manage lifecycle of inner object respect their parent.
@ManyToOne(cascade) if you use Session.persist()
operation or org.hibernate.annotations.@Cascade
if you use not JPA function Session.saveOrUpdate()
.
This is just an example, for full doc point here
For your code, if you want to automatically save Manufacturer
when saving Project
use:
@ManyToOne (fetch = FetchType.EAGER, cascade = {javax.persistence.CascadeType.PERSIST})
@JoinColumn (name = "mfr_id")
public Manufacturer getManufacturer () {
return this.manufacturer;
}
or
@Cascade(CascadeType.PERSIST)