package dev.dinauer.maven.jpa.maven.repo;

import dev.dinauer.maven.jpa.maven.Version;
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
import io.quarkus.panache.common.Parameters;
import jakarta.enterprise.context.ApplicationScoped;

import java.util.Optional;

@ApplicationScoped
public class VersionRepo implements PanacheRepositoryBase<Version, String>
{
    public Optional<Version> findOptionalByVersion(String groupId, String artifactId, String version)
    {
        return find("version = :version AND artifact.artifactId = :artifactId AND artifact.group.groupId = :groupId", Parameters.with("groupId", groupId).and("artifactId", artifactId).and("version", version)).firstResultOptional();
    }
}