question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I have three tables. The relationship between A and B, B and C is one to many. A -> B, B -> C

As a result, I want the JSON format as follows:

[
    {
        id: 1,
        ...,
        bs: [
            {
                id: 1,
                ...,
                cs: [
                    {
                        id: 1,
                        ...
                    }
                ]
            }
        ]
    }
]

So, I implemented a query as follows:

final SQLQueryFactory queryFactory;

public List<APojo> find() {
  return this.queryFactory
    .from(A)
    ...
    .leftJoin(A...., B)
    .leftJoin(B...., C)
    .transform(
      groupBy(A.id)
        .list(
          bean(
            APojo.class,
            ...,
            set(
              bean(
                BPojo.class,
                B.someProperty,
                set(
                  bean(CPojo.class, C.all())
                ).as("cs")
          )
        )
      )
    )
}

The problem is not the query. The query is executed well. But a exception for projection is being occured:

...
Caused by: java.lang.IllegalArgumentException: argument type mismatch
...

I debugged the exception and found the problem. It is occured on newInstance(Object... a)#QBean:

public T newInstance(Object... a) {
...
        } else {
            for (int i = 0; i < a.length; i++) {
                Object value = a[i];
                if (value != null) {
                    Method setter = setters.get(i);
                    if (setter != null) {
                        setter.invoke(rv, value); // <-------
                    }
                }
            }
        }
...

I expected that a instance of Set<C> is generated, but just a instance of C is actually generated. Then, when setter.invoke is invoked, the exception is occured. I don’t understand this situation.

How can I project nested set or list?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
corporalariscommented, Mar 17, 2020

I realize this is pretty much confirmed but I wanted to note I can easily get this to work with 2 layer projection but the moment I uncomment the 3rd layer I get this exception. It sure would be nice to have this all buttoned up. Workarounds for now! 😃

0reactions
devckencommented, May 7, 2019

@devcken Did you ever find a resolution to your issue? I am encountering the same problem with a nested Set projection. Thanks!

@daniel-pittman Unfortunately it is impossible. Timowest said it is a unavoidable characteristic on ORM. I think maybe it is related to lazy loading. This is all I know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A feature fusion deep-projection convolution neural network ...
The feature fusion deep-projection module is responsible for mixing Feature images of different levels and restoring them to the specified ...
Read more >
Prefrontal deep projection neurons enable cognitive ... - PubMed
These findings identify a critical role for deep PFC projection neurons in enabling set-shifting through behavioral feedback monitoring.
Read more >
Prefrontal deep projection neurons enable cognitive flexibility ...
These findings identify a critical role for deep PFC projection neurons in enabling set-shifting through behavioral feedback monitoring.
Read more >
DeepProjection: specific and robust projection of curved 2D ...
Here, we present DeepProjection (DP), a trainable projection algorithm based on deep learning. This algorithm is trained on user-generated training data to ...
Read more >
Deep Back-Projection Networks for Super-Resolution
We propose Deep Back-Projection. Networks (DBPN), that exploit iterative up- and down- sampling layers, providing an error feedback mechanism for projection ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found