S
S
Serb_NAHAL_24rus2020-09-19 12:43:43
Java
Serb_NAHAL_24rus, 2020-09-19 12:43:43

How to fix an error when generating a Hibernate query?

I'm learning how hibernate works. If I display a list of authors, then everything is collected and displayed (only memory addresses)

for (Author author:new AuthorHelper().getAuthorList()) {
            System.out.println(<b>author</b>);
        }

if i want to get first name or last name
for (Author author:new AuthorHelper().getAuthorList()
        ) {
            System.out.println(<b>author.getSecondName()</b>);
        }


then an error appears
error: cannot find symbol System.out.println(author.getSecondName());
                                     ^
  symbol:   method getSecondName()
  location: variable author of type Author


What should be done?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan, 2020-09-19
@Serb_NAHAL_24rus

Doesn't look like a Hibernate bug.
symbol: method getSecondName()
Please check if you have a secondNamefield
Do you have a getter for this field getSecondName()?
Are you using the lombok library? If so, did you forget to add @Dataor @Getter @Setterto your entities.
If added, is the annotaion processor included?

S
Serb_NAHAL_24rus, 2020-09-19
@Serb_NAHAL_24rus

Thanks!!!! Yes you are right!!! the problem was in lombok, removed these annotations, registered the usual getter-setters and it worked!!!!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question