0

I want to get actual column name that is in db from entity variable names.

Eg:

i have an entity as below,

@Entity
@Table(name="test_detail",schema = "test")
public class Test {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
@Column(name = "id")
private Long id;

@Column(name="test_status")
private Boolean testStatus;

@Column(name="test_status1")
    private Boolean testStatus1;
    }

I had populated this entity using springboot repository get/find calls.

Test t = repository.findById(1l);

I have a list L which contains the names of the colums as

['id','test_status']

i need to get the values of column names that are mentioned in the list L.In this case i dont need values present in testStatus1.

How do i do that?

or

Is there any way to get only the values for the columns mentioned in the list directly?

There are few criteria that need to be met:

  • Criteria 1 : should not use Namedqueries/@Query annotations
  • Criteria 2 : the columns in the List L might vary from request to request. it is generated dynamically.Sometimes all the columns are listed sometimes just one or two columns listed.
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    How to get actual column names based on entity variable names? - https://stackoverflow.com/questions/2921451/get-column-name-in-jpa?lq=1 – Dulaj Kulathunga Sep 05 '19 at 13:43
  • JPA/EclipseLink - Retrieve Columns Names - https://stackoverflow.com/questions/3657968/jpa-eclipselink-retrieve-columns-names/25520204#25520204 – Dulaj Kulathunga Sep 05 '19 at 13:57
  • How to get Column names of JPA entity -https://stackoverflow.com/questions/46335682/how-to-get-column-names-of-jpa-entity – Dulaj Kulathunga Sep 05 '19 at 13:58

0 Answers0