1

I have a question how I can do so that in spring my table is recognized with the first capital letter, is made in postgresql

@Entity
@Table(name="System_user") 

public class Dashboard { 

    @Id
    @Column(name = "username")
    String username;

get..
set...
}

it generates an error and I change it as shown below

@Table("\"System_user\"")

but he still doesn't recognize me

0

2 Answers 2

0

As we discussed in the comments, the issue was in dialect.
Latest dialect for now - org.hibernate.dialect.PostgreSQL95Dialect

The issue solved this dialect: <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>


Answer to your HQL-code:

I would suggest using TypedQuery as it returns not just a list, but list of your object.

Furthermore, u are using the same session to transfer data. This is bad for the program. Always do like Open session - transfer data - close session.

Try this code:


public List<Vw_dh_assay> listAssayReport(double year, String project_id, String hole_id) {
        List<Vw_dh_assay> list = new ArrayList<>();
        Session session;

        try {
            session = this.sessionFactory.openSeesion();
            TypedQuery<Vw_dh_assay> query = session.createQuery("from Vw_dh_assay where year = :year AND project_id = :project_id  AND hole_id = :hole_id", Player.class);
            query.setParameter("year", year);
            query.setParameter("project_id", project_id);
            query.setParameter("hole_id", hole_id);

            list = query.getResultList();

            System.out.println(list);

            session.clear();
            session.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return list;
    }
0

this is my code DAO @Antonio112009

@Override
    public List<Vw_dh_assay> listAssayReport(double year, String project_id, String hole_id) {
        Session session = this.sessionFactory.getCurrentSession();
        String query = ("SELECT DISTINCT year,project_id,hole_id from "
                + "Vw_dh_assay where year = :year AND project_id = :project_id  AND hole_id = :hole_id");
        List result = session.createQuery(query).setParameter("year", year).setParameter("project_id", project_id)
                .setParameter("hole_id", hole_id).list();

        System.out.println(result);
        return result;
    }
1
  • Never add here code... This is only for answers) Only in your question u can do that... Commented Sep 7, 2019 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.