View Javadoc

1   /*
2    *  Copyright 2004 University of Hannover
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package olr.samples;
18  
19  import olr.Olr;
20  import olr.om.RdfUser;
21  import olr.om.RdfUserPeer;
22  
23  /***
24   * Sample application to demonstrate the usage of the Java object model
25   * @version $Id: TorqueBasicsSample.java,v 1.3 2004/08/02 18:36:42 roku Exp $
26   */
27  public class TorqueBasicsSample
28  {   
29      public static void main(String[] args)
30      {        
31          RdfUser user = new RdfUser();
32  
33          user.setFirstName("Bill");
34          user.setLastName("Gates");
35          user.setLogin("bgates");
36          user.setPassword("m--rosoft");
37  
38          try
39          {
40              Olr.initTorque();
41              user.save();
42              System.out.print("Created user ");
43              
44              // Select the user from db
45              user = RdfUserPeer.retrieveByPK(user.getPrimaryKey());            
46              System.out.println(user.getFirstName() + " " + user.getLastName());
47              
48              RdfUserPeer.doDelete(user);
49              System.out.println("User deleted.");            
50          } 
51          catch (Exception e)
52          {
53              System.err.println("Could not create a new user:" + e);
54          }
55      }
56  }