This discussion is archived
1 Reply Latest reply: Apr 18, 2013 6:41 AM by cdelahun RSS

Fetching propertyfield name from JPA Entity

998524 Newbie
Currently Being Moderated
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 Pro
    Currently Being Moderated
    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

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points