title: OOP & Transactions between objects JAVA
body: <p>i hope somebody can help me with this, i have 2 clases User and Adress
  both have addNewUser() and addNewAdress() this methods do a transactions with preparedsatement, but i dont know how to join the objets because when i add a new user i need to add a new adrees with the user id.</p>
  
  <pre><code>class User{
    public boolean addNewUser(){
          Connection con = conecctions.getconnection;
  
      Statement stmt = null;
      Boolean result = false;
  
  
              try {
  
          stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                  ResultSet.CONCUR_UPDATABLE);
  
          PreparedStatement addUser = 
             con.prepareStatement(query);
            addUser.setBoolean(1, false);
            addUser.setString(1, "name");
  
          con.commit();
  
            ...
            ...
            ...
          Adress newAdress = new Adress("new_user_id", "addres");
        newAdrees.addNewAdress();
  
    }
  </code></pre>
  
  <p>i think do that its wrong, how can i implement composition? and use the same commit for both methods. thanks!</p>