Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullpointer using inet-type #9

Open
hannez82 opened this issue Oct 17, 2017 · 1 comment
Open

Nullpointer using inet-type #9

hannez82 opened this issue Oct 17, 2017 · 1 comment

Comments

@hannez82
Copy link

I get a nullpointer when using the inet-type on postgres 10/jdbc-4.2.1.4
Caused by: java.lang.NullPointerException
at org.postgresql.jdbc.TypeInfoCache.getOidStatement(TypeInfoCache.java:256)

Updating the method nullSafeSet to:

  @Override
    public void nullSafeSet(PreparedStatement preparedStatement, Object o, int i, SessionImplementor sessionImplementor) throws HibernateException, SQLException {

        if (o == null) {
            preparedStatement.setNull(i, java.sql.Types.OTHER);
        } else {
            PGobject object = new PGobject();
            object.setValue(((InetAddress) o).getHostAddress());
            **object.setType("inet");**
            preparedStatement.setObject(i, object);
        }
    }

Fixes the problem

@The-Alchemist
Copy link
Owner

Could you submit a PR?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants