title: kotlin: cannot get validation api's annotation
body: <p>==========UPDATE==========</p>
  
  <p>when i change the annotation to @get:NotNull , @get:Min and @get:Max, the hibernate-validator can read these annotations success. </p>
  
  <p>But what i still want to know is: </p>
  
  <p><strong>why the validation-api's annotation, such as @NotNull , @Min and @Max cannot be used on data class's members directly, while JPA's annotations can be????</strong></p>
  
  <p>==========Bellow is the origin question===========</p>
  
  <p>when i tried to use validation-api's annotation on data class, the Validator class (from hibernate-validator) cannot get the annotations, so the validation failed.</p>
  
  <p>i wrote a test case, which include 3 data classes:</p>
  
  <ul>
  <li>1st one use JPA annotation @Column and @Id, which can be read successfully by test case.</li>
  <li>2nd one use validation-api annotation @NotEmpty, @Min,@Max on members, these annotation cannot be read by test case</li>
  <li>3rd one use validation-api annotation @get:NotEmpty, @get:Min, @get:Max, the test case cannot read these annotation.</li>
  </ul>
  
  <p>The target and retention of @Column , @NotNull, @Min and @Max are all:
    RUNTIME and FIELD</p>
  
  <p>So, what happened in the behind? how can i use the validation annotations properly?</p>
  
  <p>here is the test case:</p>
  
  <pre><code>import org.hibernate.validator.constraints.NotEmpty
  import org.junit.Test
  import javax.persistence.Column
  import javax.persistence.Id
  import javax.validation.constraints.Max
  import javax.validation.constraints.Min
  import kotlin.reflect.KFunction
  import kotlin.reflect.KProperty
  import kotlin.reflect.jvm.javaField
  import kotlin.reflect.jvm.javaMethod
  
  class KotlinFeatureTest2 {
      @Test
      fun test_get_annotation() {
          // can get field's annotation for BeanUseJPAAnnotation success
          println("Getting field annotations for BeanUseJPAAnnotation :")
          BeanUseJPAAnnotation::class.members.forEach {
              if (it is KProperty) {
                  val field = it.javaField
                  println("${field?.name}'s annotations:")
                  field?.annotations?.forEachIndexed { i, an -&gt;
                      println("        $i is: $an")
                  }
              }
          }
  
          println("--------------------")
          println("Getting field annotations for BeanUseValidationAnnotation :")
          // CANT get field's annotation for BeanUseJPAAnnotation success
          BeanUseValidationAnnotation::class.members.forEach {
              if (it is KProperty) {
                  val field = it.javaField
                  println("${field?.name}'s annotations:")
                  field?.annotations?.forEachIndexed { i, an -&gt;
                      println("        $i is: $an")
                  }
              }
          }
  
          println("--------------------")
          println("Getting field annotations for BeanUseValidationAnnotationOnMethod :")
          // CANT get field's annotation for BeanUseJPAAnnotation success
          BeanUseValidationAnnotationOnMethod::class.members.forEach {
              if (it is KFunction) {
                  val method = it.javaMethod
                  println("${method?.name}'s annotations: ")
                  method?.annotations?.forEachIndexed { i, an -&gt;
                      println("        $i is: $an")
                  }
              }
          }
      }
  }
  
  data class BeanUseJPAAnnotation(
          @Column(name = "id") @Id val id: String,
          @Column(name = "user_name") val name: String)
  
  data class BeanUseValidationAnnotation(
          @NotEmpty(message = "name can not be empty")
          val name: String,
  
          @Min(value = 1)
          @Max(value = 100)
          val age: Int
  )
  
  data class BeanUseValidationAnnotationOnMethod(
          @get:NotEmpty(message = "name can not be empty")
          val name: String,
  
          @get:Min(value = 1)
          @get:Max(value = 100)
          val age: Int)
  </code></pre>
  
  <p>and here are the output of this test case:</p>
  
  <pre><code>Getting field annotations for BeanUseJPAAnnotation :
  id's annotations:
      0 is: @javax.persistence.Column(nullable=true, unique=false, precision=0, name=id, length=255, scale=0, updatable=true, columnDefinition=, table=, insertable=true)
      1 is: @javax.persistence.Id()
  name's annotations:
      0 is: @javax.persistence.Column(nullable=true, unique=false, precision=0, name=user_name, length=255, scale=0, updatable=true, columnDefinition=, table=, insertable=true)
  --------------------
  Getting field annotations for BeanUseValidationAnnotation :
  age's annotations:
  name's annotations:
  --------------------
  Getting field annotations for BeanUseValidationAnnotationOnMethod :
  component1's annotations: 
  component2's annotations: 
  copy's annotations: 
  equals's annotations: 
  hashCode's annotations: 
  toString's annotations: 
  </code></pre>