JDO Architecture: One-to-Big Relationship and Cascading Deletion

I'm new to object-oriented database projects, and I'm trying to figure out how I should structure my classes in JDO for the Google engine, especially from one to many relationships.

Let's say that Im is building a structure for a department store where there are many departments, and each department has many products. Therefore, Id wants to have a class called Department, with a variable that is a list of the Product class.

@PersistenceCapable 
public class Department { 
    @PrimaryKey 
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
    private String deptID; 

    @Persistent 
    private String departmentName; 

    @Persistent 
    private List<Product> products; 

}

@PersistenceCapable 
public class Product { 
    @PrimaryKey 
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
    private String productID; 

    @Persistent 
    private String productName; 

}

(, ). , : OOD ? : , , , ?

+3
1

. . App Engine .

@Persistent
@Element(dependent = "true")
private List<Product> products; 
+2

Source: https://habr.com/ru/post/1749129/


All Articles