SelectnewTopicfrom 'mysql SQL statement generation exception

Source: Internet
Author: User
An error occurred while generating the SQL statement Causedby: com. mysql. jdbc. exceptions. exceptions: failed; Hibernate: selecttopic0 _. idascol_0_0 _, topic0 _. titleascol_1_0 _, topic0 _. keyworda.

Select new Topic from 'mysql SQL statement generation error Caused by: com. mysql. jdbc. exceptions. jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; Hibernate: select topic0 _. id as col_0_0 _, topic0 _. title as col_1_0 _, topic0 _. keyword

Select new Topic from 'mysql SQL statement generation Error
Caused:
Com. mysql. jdbc. exceptions. jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;


Hibernate:
Select
Topic0 _. id as col_0_0 _,
Topic0 _. title as col_1_0 _,
Topic0 _. keyword as col_2_0 _,
Topic0 _. status as col_3_0 _,
Topic0 _. recommend as col_4_0 _,
Topic0 _. publishName as col_5_0 _,
Topic0 _. publish_date as col_6_0 _,
Topic0 _. channel_name as col_7_0 _,
Topic0 _. author as col_8_0 _,
. As col_9_0 _
From
T_topic topic0 _
Inner join
T_attachment attachment1 _
On topic0 _. id = attachment1 _. topic_id
Where
1 = 1
And topic0 _. status = 1
And topic0 _. channel_id = 142 limit?




"Select new Topic (t. id, t. title, t. keyword, t. status, t. recommend, t. publishName, t. publishDate, t. channel_name, t. author, t. attachments )";


The constructor method is used to set the query.
However, when we encounter this onetoworkflow, it seems that we cannot do this.

When the Setattachments in the Topic is obtained by hibernate in the mysql database, it becomes an incorrect SQL statement.


Only select new Topic can be removed and directly written as from Topic.

Tell me who knows how to solve this problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.