Out of curiosity I would like to migrate a Play! 1.2.3 Java application to Play! 2.0, but I'm having difficulty understanding the new application controller. I've examined the three example applications, but they've been of little help to me as I'm not an experienced programmer. Here is a stripped down example of how I currently approach an application controller in Play! 1.2.3.
The Master and Detail classes:
@Entity
public class Master extends Model {
public String name;
public String address;
@OneToMany(cascade=CascadeType.ALL,mappedBy="detailId")
public List<Detail> details;
}
@Entity
public class Detail extends Model {
public String pet;
@JoinColumn(name="detail_id")
@ManyToOne
public Master detailId;
}
The Application class:
public class Application extends Controller {
public static void master(Long id) {
Master master = Master.findById(id);
render(master);
}
public static void saveMaster(final Master master) {
master.save();
}
public static void saveDetail(Long id, final Detail detail) {
Master master = Master.findById(id);
detail.detailId = master;
detail.save();
master.details.add(detail);
master.save();
master(id)
}
}
I know it's far from elegant but it works and code is easy for me to follow. I would like to do something similar using the new framework and any help would be greatly appreciated.