Issue #2470: com.objectdb.o.InternalException: java.lang.NullPointerException

Type: Bug ReoprtVersion: 2.8.1Priority: NormalStatus: ActiveReplies: 7
#1

Hello,

I have a CUIT entity, with a OneToMany List field called razonesSociales (that can be null):
@OneToMany (mappedBy = "cuit") private List razonesSociales;

When I run this query it works ok:
SELECT COUNT(item.sysID) FROM CUIT item WHERE  ( (item.sysStatus.sysID=1)  AND  (item.razonesSociales.cuenta.vendedor.sysID=1000200) ) 

But in the Nosis entity, that have a CUIT field, when I run this query I get a com.objectdb.o.InternalException: java.lang.NullPointerException
SELECT COUNT(item.sysID) FROM Nosis item WHERE  ( (item.sysStatus.sysID=1)  AND  (item.cuit.razonesSociales.cuenta.vendedor.sysID=1000200) ) 

The decompiler shows the exception in the marked line, because var3.ag() is null:

static PLN g(PLN var0, VAR var1, QUN var2) {
    if (var0 == null) {
        return null;
    } else {
        if (var2 instanceof JNN) {
            if (var2.D() && !((PLN)var0).s()) {
                return null;
            }
            JNN var3 = (JNN)var2;
            if (!var3.ag().e().isEntityOrObject()) {  <<<< NullPointerException
                if (((PLN)var0).r(var3)) {
                    return (PLN)var0;
                }
                return null;
            }
        }
        if (var1.e().isContainer()) {
            BIT var4 = var2.s(var1.H());
            if (var4 != null && !((PLN)var0).f().e(var4)) {
                var0 = new EQP((PLN)var0, var1);
            }
        }
        Object var5 = new FIP((PLN)var0, var2);
        if (var2.D()) {
            var5 = new ANP((PLN)var5);
        }
        return (PLN)var5;
    }
}

This is the stack trace:

com.objectdb.o.InternalException: java.lang.NullPointerException: null
java.lang.NullPointerException
at com.objectdb.o.WVP.g(WVP.java:584)
at com.objectdb.o.WVP.a(WVP.java:245)
at com.objectdb.o.WVP.a(WVP.java:218)
at com.objectdb.o.WVP.d(WVP.java:183)
at com.objectdb.o.WVP.e(WVP.java:133)
at com.objectdb.o.WHP.c(WHP.java:352)
at com.objectdb.o.WHP.e(WHP.java:255)
at com.objectdb.o.WHP.b(WHP.java:187)
at com.objectdb.o.WHP.b(WHP.java:181)
at com.objectdb.o.WHP.b(WHP.java:181)
at com.objectdb.o.WHP.b(WHP.java:123)
at com.objectdb.o.QPN.g(QPN.java:88)
at com.objectdb.o.QRC.j(QRC.java:213)
at com.objectdb.o.QRM.ZX(QRM.java:273)
at com.objectdb.o.MST.ZX(MST.java:1019)
at com.objectdb.o.WRA.ZX(WRA.java:313)
at com.objectdb.o.WSM.ZX(WSM.java:117)
at com.objectdb.o.QRR.k(QRR.java:260)
at com.objectdb.o.QRR.i(QRR.java:154)
at com.objectdb.jpa.JpaQuery.getSingleResult(JpaQuery.java:755)
...
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)

I guess that it's a bug.

Best Regards,
Pablo.

#2

Yes, it is probably a bug, thank you for this report. If you can send a sample database on which we can run the query and see the exception it would be a great help.

ObjectDB Support
#3

Sorry for answer through a new ticket, but I can't find the post reply option in the original one.

I can't send you the database and code, because they are about 8GB and 120K lines of code.
Is it not enough with the info that I have sent you?
Is there any other info that I can add?

Best Regards,
Pablo.

#4

The Reply button is at the bottom. What browser are you using? Strange that it is not shown.

As the exception is thrown during query compilation, even an empty database with that schema may be useful for reproducing the issue.

ObjectDB Support
#5

About database, it is going to take me a lot of work to delete data on 120 entities,  and then load bulk data in about 60 entities to load at least one Nosis object to reproduce the problem, because without no data I guess that a "SELECT COUNT(item.sysID) FROM Nosis item WHERE..." query is not going to generate the error.

BTW, if I need to send you code or database, I can't find a private option to do that.
It is all confidential information, I can't post it in a public place!

Best regards,
Pablo.

#6

Maybe you can create a new small database with just one Nosis and one CUIT and no confidential information to demonstrate the exception. 

ObjectDB Support
#7

The problem is that I need to delete data on 120 entities, and then load bulk data in about 60 entities to load one Nosis.
That process is going to take me several hours.

Is it not enough information to find the bug the line in the code that causes the exception when you query a null collection that is two step deep (item.item.collection) ?
(please check, all that information is in the original post)

Best regards,
Pablo.

#8

The suggestion on #6 above is to create a new empty database and then persist 2 empty instances of the relevant classes, rather than to use a production database and delete its content.

Unfortunately the stack trace is insufficient on this case to understand the cause.

ObjectDB Support

Reply