Hi Pinaki,
Most of the recent documentations also suggest that the distribution policy
only applies to the root entity.  However, I'm experiencing the distribution
policy being hit for even relations of the root.  here is sample code of
what i am doing:


@Entity
@Table(name="person")
@Cacheable
public class Person{
    
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
        protected Long uid;

    private Long addressID = null;
     
    @ManyToOne(cascade=CascadeType.PERSIST)
    @JoinColumn(name="addressID")
    @ForeignKey
    private Addresses address;
    
    public Person(){}
    
    
        public Long getAddressID() {
                return addressID;
        }

        public void setAddressID(Long addressID) {
                this.addressID = addressID;
        }

        public Addresses getAddress() {
                return address;
        }

        public void setAddress(Addresses address) {
//              if(address.getPersons()==null){
//                      address.setPersons(new ArrayList<Persons>());
//              }
//              address.getPersons().add(this);
//              this.address = address;
        }
}


Address.java
@Entity
@Table(name="addresses")
@Cacheable
public class Addresses extends PersistenceObject {
        @Id
        @GeneratedValue(strategy=GenerationType.IDENTITY)
        protected Long uid;

        private static final long serialVersionUID = -8407302786991570250L;
        
        @OneToMany(mappedBy="address", cascade=CascadeType.PERSIST)
        private List<Person> persons;
        
        public Addresses(){
                
        }

        <-- other stuff ommitted for brevity -->
        
        
}



        public void testCreate(){

                Person person = new Person();
                
                //create some address to assign to this person
                String street1 = "123 Main Street";
                String street2 = null;
                String city = "Palo Alto";
                String state = "CA";
                String zip = "123456";
                Addresses address = new Addresses(street1, street2, city, 
state, zip);
                
                person.setAddress(address);

                em.persist(person);
        }



so if i do

Person p = Person();
Address a = new Address();
p.setAddress(a);
em.persist(p);

i see that the distibutionpolicy is consulted for both Person and Address. 
Am I configuring something wrong here?  Here is the excerpt from my
persistence.xml:

<property name="openjpa.BrokerFactory" value="slice"/>
                        <property name="openjpa.slice.Names"  
value="platform,platform1,platform2"/>
                        <property name="openjpa.slice.Master"  
value="platform"/>
                        
                        <property name="openjpa.slice.Lenient" value="true"/>
                             
                        <property name="openjpa.ConnectionDriverName"
                                  value="com.mysql.jdbc.Driver"/>
                        <property name="openjpa.ConnectionUserName" 
value="root"/>
                        <property name="openjpa.ConnectionPassword" 
value="99nfirst"/>
                        <property name="openjpa.slice.platform.ConnectionURL"   
 
                                  value="jdbc:mysql://127.0.0.1:3306/platform"/>
                        <property name="openjpa.slice.platform1.ConnectionURL"  
  
                                  
value="jdbc:mysql://127.0.0.1:3306/platform1"/>
                        <property name="openjpa.slice.platform2.ConnectionURL"  
  
                                  
value="jdbc:mysql://127.0.0.1:3306/platform2"/>
                        
                        <property name="openjpa.slice.DistributionPolicy" 
                                      
value="com.edelements.platform.service.openjpa.ShardDistributionPolicy"/>
                        <property name="openjpa.slice.FinderTargetPolicy" 
                                          
value="com.edelements.platform.service.openjpa.ShardFinderTargetPolicy"/>
                        <property name="openjpa.slice.ReplicatedTypes" 
                                          
value="com.edelements.platform.model.Users,com.edelements.platform.model.Permissions,com.edelements.platform.model.Resources"/>




--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Slice-extension-of-OpenJPA-for-distributed-databases-tp209691p6339113.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to