I am currently trying to setup a connection between my database and my application, running on k8s, all running on DigitalOcean. My database is accepting all incoming connections for testing purposes right now. That enables me to let my application run locally but still connect to my remote database via Hibernate.

Problem: Running locally is no problem at all - it runs queries without any problem. But when my k8s pod application tries to run queries, the following error comes up:

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [SELECT c from User c WHERE c.email = :email]
	at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:79)
	at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:103)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:220)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:144)
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:113)
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:73)
	at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:162)
	at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:622)
	at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:734)
	... 26 common frames omitted
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped
	at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:169)
	at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:91)
	at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:77)

A little snippet from my User class:

public class User {

    @GeneratedValue(strategy = GenerationType.AUTO, generator = "system-uuid")
    @Column(name = "id", nullable = false)
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    private String id;
    private String firstname;
    private String lastname;
    private String organizationID;
    private String email;
    private String password;
    private boolean isActivated;

My question: Why does it work locally and not in my pod? To me, it does not seem to have anything to do with the connection, or am I incorrect?

Thanks in advance, I hope to get an answer soon.

Kind regards, Alex

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer