// Path: metacat-connector-polaris/src/main/java/com/netflix/metacat/connector/polaris/store/entities/PolarisDatabaseEntity.java
// @Getter
// @AllArgsConstructor
// @NoArgsConstructor
// @Builder(toBuilder = true)
// @EqualsAndHashCode
// @Entity
// @ToString(callSuper = true)
// @Table(name = "DBS")
// 
// public class PolarisDatabaseEntity {
//     @Version
//     private Long version;
// 
//     @Basic
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     @Column(name = "id", nullable = false, unique = true, updatable = false)
//     private String dbId;
// 
//     @Basic
//     @Column(name = "name", nullable = false, unique = true, updatable = false)
//     private String dbName;
// 
//     @Basic
//     @Column(name = "location", updatable = false)
//     private String location;
// 
//     /**
//      * Constructor for Polaris Database Entity.
//      * @param dbName database name
//      * @param location database location.
//      */
//     public PolarisDatabaseEntity(final String dbName,
//                                  final String location) {
//         this.dbName = dbName;
//         this.location = location;
//     }
// }


import com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.Optional;
package com.netflix.metacat.connector.polaris.store.repos;



/**
 * JPA repository implementation for storing PolarisDatabaseEntity.
 */
@Repository
public interface PolarisDatabaseRepository extends JpaRepository<PolarisDatabaseEntity, String>,
    JpaSpecificationExecutor {

    /**
     * Fetch database entry.
     * @param dbName database name
     * @return database entry, if found
     */
    Optional<PolarisDatabaseEntity> findByDbName(@Param("dbName") final String dbName);

    /**
     * Check if database with that name exists.
     * @param dbName database name to look up.
     * @return true, if database exists. false, otherwise.
     */
    boolean existsByDbName(@Param("dbName") final String dbName);

    /**
     * Delete database entry by name.
     * @param dbName database name.
     */
    @Modifying
    @Query("DELETE FROM PolarisDatabaseEntity e WHERE e.dbName = :dbName")
    void deleteByName(@Param("dbName") final String dbName);

    /**
     * Fetch databases.
     * @param page pageable.
     * @return database entities.
     */
    @Query("SELECT e FROM PolarisDatabaseEntity e")
// Path: metacat-connector-polaris/src/main/java/com/netflix/metacat/connector/polaris/store/entities/PolarisDatabaseEntity.java
// @Getter
// @AllArgsConstructor
// @NoArgsConstructor
// @Builder(toBuilder = true)
// @EqualsAndHashCode
// @Entity
// @ToString(callSuper = true)
// @Table(name = "DBS")
// 
// public class PolarisDatabaseEntity {
//     @Version
//     private Long version;
// 
//     @Basic
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     @Column(name = "id", nullable = false, unique = true, updatable = false)
//     private String dbId;
// 
//     @Basic
//     @Column(name = "name", nullable = false, unique = true, updatable = false)
//     private String dbName;
// 
//     @Basic
//     @Column(name = "location", updatable = false)
//     private String location;
// 
//     /**
//      * Constructor for Polaris Database Entity.
//      * @param dbName database name
//      * @param location database location.
//      */
//     public PolarisDatabaseEntity(final String dbName,
//                                  final String location) {
//         this.dbName = dbName;
//         this.location = location;
//     }
// }


// Path: metacat-connector-polaris/src/main/java/com/netflix/metacat/connector/polaris/store/repos/PolarisDatabaseRepository.java
import com.netflix.metacat.connector.polaris.store.entities.PolarisDatabaseEntity;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.Optional;

package com.netflix.metacat.connector.polaris.store.repos;



/**
 * JPA repository implementation for storing PolarisDatabaseEntity.
 */
@Repository
public interface PolarisDatabaseRepository extends JpaRepository<PolarisDatabaseEntity, String>,
    JpaSpecificationExecutor {

    /**
     * Fetch database entry.
     * @param dbName database name
     * @return database entry, if found
     */
    Optional<PolarisDatabaseEntity> findByDbName(@Param("dbName") final String dbName);

    /**
     * Check if database with that name exists.
     * @param dbName database name to look up.
     * @return true, if database exists. false, otherwise.
     */
    boolean existsByDbName(@Param("dbName") final String dbName);

    /**
     * Delete database entry by name.
     * @param dbName database name.
     */
    @Modifying
    @Query("DELETE FROM PolarisDatabaseEntity e WHERE e.dbName = :dbName")
    void deleteByName(@Param("dbName") final String dbName);

    /**
     * Fetch databases.
     * @param page pageable.
     * @return database entities.
     */
    @Query("SELECT e FROM PolarisDatabaseEntity e")
    Slice<PolarisDatabaseEntity> getDatabases(Pageable page);