2

I am using spring boot, spring data JPA, I am searching for solution to get all column names of a given table. But could not found as per my requirements

Not want a solution with native query.Looking for general solution using spring data abstraction.

I am able to get the column names using normal java but i want to fetch them using spring data JPA.

Akki
  • 107
  • 1
  • 5
  • 14
  • 1
    Possible Duplicate of https://stackoverflow.com/questions/31239812/is-there-any-simplest-way-to-get-table-metadata-column-name-list-information – Romil Patel Mar 05 '19 at 09:32
  • Possible duplicate of [Is there any Simplest way to get Table metadata (column name list) information, in Spring Data JPA ? which could I use on universal database](https://stackoverflow.com/questions/31239812/is-there-any-simplest-way-to-get-table-metadata-column-name-list-information) – xerx593 Mar 05 '19 at 12:01

1 Answers1

3

they are several ways

public interface TableMetadataRepository extends JpaRepository<TableMetadata, TableMetadataKey>
{
  TableMetadata findByTableName(String tableName);
}

then you can go for

List<TableMetadata> metadata = tableMetadataRepository.findAll()
TableMetadata metadataofspecifictable = tableMetadataRepository.findByTableName("urtable");
abhinavsinghvirsen
  • 1,853
  • 16
  • 25