Home | History | Annotate | Download | only in jpa
      1 /**
      2  * Copyright (C) 2010 Google, Inc.
      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 com.google.inject.persist.jpa;
     18 
     19 import javax.persistence.Entity;
     20 import javax.persistence.GeneratedValue;
     21 import javax.persistence.Id;
     22 
     23 /** @author Dhanji R. Prasanna (dhanji (at) gmail.com) */
     24 @Entity
     25 public class JpaTestEntity {
     26   private Long id;
     27   private String text;
     28 
     29   @Id @GeneratedValue
     30   public Long getId() {
     31     return id;
     32   }
     33 
     34   public void setId(Long id) {
     35     this.id = id;
     36   }
     37 
     38   public String getText() {
     39     return text;
     40   }
     41 
     42   public void setText(String text) {
     43     this.text = text;
     44   }
     45 
     46   @Override
     47   public boolean equals(Object o) {
     48     if (this == o) {
     49       return true;
     50     }
     51     if (o == null || getClass() != o.getClass()) {
     52       return false;
     53     }
     54 
     55     JpaTestEntity that = (JpaTestEntity) o;
     56 
     57     if (id != null ? !id.equals(that.id) : that.id != null) {
     58       return false;
     59     }
     60     if (text != null ? !text.equals(that.text) : that.text != null) {
     61       return false;
     62     }
     63 
     64     return true;
     65   }
     66 
     67   @Override
     68   public int hashCode() {
     69     int result = id != null ? id.hashCode() : 0;
     70     result = 31 * result + (text != null ? text.hashCode() : 0);
     71     return result;
     72   }
     73 }
     74