1 Reply Latest reply: Apr 18, 2013 8:41 AM by Cdelahun-Oracle RSS

    Fetching propertyfield name from JPA Entity

    998524
      Hello Members,
      I want to fetch Entity's property name.Is it possible?
      For eg. in my ABC entity class, I want to fetch auditFirmDescription and auditFirmType .Is JPA providing such functionality or do we have to fetch by manual coding?

      @Entity
      @Table(name = "mst_audit_firm")
      public class ABC
      {
           private String auditFirmDescription;
           private String auditFirmType;

      @Column(name = "audit_firm_description")
           public String getAuditFirmDescription() {
                return this.auditFirmDescription;
           }

           public void setAuditFirmDescription(String auditFirmDescription) {
                // In this application, we are storing data in lowercase only
                this.auditFirmDescription = auditFirmDescription.toLowerCase();
           }

      @Column(name = "audit_firm_type")
           public String getAuditFirmType() {
                return this.auditFirmType;
           }

           public void setAuditFirmType(String auditFirmType) {
                this.auditFirmType = auditFirmType;
           }
      }     

      Any help is appreciated.

      Edited by: 995521 on Apr 17, 2013 9:28 PM
        • 1. Re: Fetching propertyfield name from JPA Entity
          Cdelahun-Oracle
          Not sure what exactly you are after. You can query for the ABC entity and then call getAuditFirmDescription() etc, or you can query for the values directly, for example "select abc.auditFirmDescription, abc.auditFirmType from ABC abc" to get a list of Object[] containing two string values. Please elaborate if this is not what you are after.

          You might look at some of the JPA tutorials such as this one:
          http://www.vogella.com/articles/JavaPersistenceAPI/article.html