public void setUserSquare(int squareId) {
   for (Square square : squares) {
     if (square.getId() == squareId) {
       this.userSquare = square;
       return;
     }
   }
 }
Beispiel #2
0
  public static void loadCache() {
    // Rectangle
    Rectangle rectangle = new Rectangle();
    rectangle.setId("1");
    cache.put(rectangle.getId(), rectangle);

    // Square
    Square square = new Square();
    square.setId("2");
    cache.put(square.getId(), square);

    // Circle
    Circle circle = new Circle();
    circle.setId("3");
    cache.put(circle.getId(), circle);
  }
 public void testEmbeddableExplicitAccessStrategy() throws Exception {
   Square square = new Square();
   Position pos = new Position(10, 15);
   square.setPosition(pos);
   Session s = openSession();
   s.persist(square);
   Transaction tx = s.beginTransaction();
   tx.commit();
   s.clear();
   tx = s.beginTransaction();
   square = (Square) s.get(Square.class, square.getId());
   assertEquals(10, square.getPosition().x);
   try {
     square.getPosition().getX();
     fail();
   } catch (RuntimeException e) {
     // success
   }
   s.delete(square);
   tx.commit();
   s.close();
 }