Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7914179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:01:32+00:00 2026-06-03T14:01:32+00:00

Maybe I’m not seeing it, but what’s wrong with specifying the group? Difficulty querying

  • 0

Maybe I’m not seeing it, but what’s wrong with specifying the group?

Difficulty querying the database (currently empty):

public void persist(Msg message) {
    LOG.info("\t" + message);
    LOG.info("isOpen?" + em.isOpen());
    em.getTransaction().begin();
    int id = message.getId();
    TypedQuery<Notes> q = em.createQuery("SELECT  n "
            + "FROM Notes n WHERE n.messageId = :messageId "
            + "AND n.group = :group", Notes.class);
    q.setParameter("messageId", message.getId()).setParameter("group", message.getGroup());
    List<Notes> results = q.getResultList();
    em.getTransaction().commit();
    for (Notes o : results) {
        LOG.info("object is \n\n" + o);
    }
}

stack trace:

run:
May 10, 2012 7:17:17 AM net.bounceme.dur.usenet.controller.PropertiesReader getProps
INFO: NNTP.loadMessages...
[EL Info]: 2012-05-10 07:17:27.343--ServerSession(29959998)--EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
[EL Severe]: 2012-05-10 07:17:29.315--ServerSession(29959998)--Local Exception Stack: 
Exception [EclipseLink-8025] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.JPQLException
Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
Exception Description: Syntax error parsing the query [Notes.getByIdAndGroup: SELECT DISTINCT n FROM Notes n WHERE n.messageId = :messageId AND n.group=group], line 1, column 74: unexpected token [group].
Internal Exception: NoViableAltException(34@[792:1: comparisonExpressionRightOperand returns [Object node] : (n= arithmeticExpression | n= nonArithmeticScalarExpression | n= anyOrAllExpression );])
    at net.bounceme.dur.usenet.swing.Frame.panelWithTable1PropertyChange(Frame.java:121)
    at net.bounceme.dur.usenet.swing.Frame.access$100(Frame.java:12)
    at net.bounceme.dur.usenet.swing.Frame$2.propertyChange(Frame.java:51)

database:

thufir@dur:~$ 
thufir@dur:~$ mysql -u java -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 141
Server version: 5.1.58-1ubuntu1 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> describe nntp.notes;
+------------+------------+------+-----+---------+-------+
| Field      | Type       | Null | Key | Default | Extra |
+------------+------------+------+-----+---------+-------+
| ID         | bigint(20) | NO   | PRI | NULL    |       |
| GROUP_ID   | int(11)    | NO   |     | NULL    |       |
| STAMP      | date       | NO   |     | NULL    |       |
| NOTE       | text       | YES  |     | NULL    |       |
| MESSAGE_ID | int(11)    | NO   |     | NULL    |       |
| GROUP      | text       | NO   |     | NULL    |       |
+------------+------------+------+-----+---------+-------+
6 rows in set (0.03 sec)

mysql> quit;
Bye
thufir@dur:~$ 

Should this class be Note or Notes? Similarly should the table be Note or Notes? Maybe it doesn’t matter.

Entity:

package net.bounceme.dur.usenet.controller;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "notes", catalog = "nntp", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Notes.findAll", query = "SELECT n FROM Notes n"),
    @NamedQuery(name = "Notes.findById", query = "SELECT n FROM Notes n WHERE n.id = :id"),
    @NamedQuery(name = "Notes.findByGroupId", query = "SELECT n FROM Notes n WHERE n.groupId = :groupId"),
    @NamedQuery(name = "Notes.findByStamp", query = "SELECT n FROM Notes n WHERE n.stamp = :stamp"),
    @NamedQuery(name = "Notes.findByMessageId", query = "SELECT n FROM Notes n WHERE n.messageId = :messageId"),
    @NamedQuery(name = "Notes.getByIdAndGroup", query = "SELECT DISTINCT n FROM Notes n WHERE n.messageId = :messageId AND n.group=group"),
})
public class Notes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID", nullable = false)
    private Long id;
    @Basic(optional = false)
    @Column(name = "GROUP_ID", nullable = false)
    private int groupId;
    @Basic(optional = false)
    @Column(name = "STAMP", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date stamp;
    @Lob
    @Column(name = "NOTE", length = 65535)
    private String note;
    @Basic(optional = false)
    @Column(name = "MESSAGE_ID", nullable = false)
    private int messageId;
    @Basic(optional = false)
    @Lob
    @Column(name = "GROUP", nullable = false, length = 65535)
    private String group;

    public Notes() {
    }

    public Notes(Long id) {
        this.id = id;
    }

    public Notes(Long id, int groupId, Date stamp, int messageId, String group) {
        this.id = id;
        this.groupId = groupId;
        this.stamp = stamp;
        this.messageId = messageId;
        this.group = group;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }

    public Date getStamp() {
        return stamp;
    }

    public void setStamp(Date stamp) {
        this.stamp = stamp;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public int getMessageId() {
        return messageId;
    }

    public void setMessageId(int messageId) {
        this.messageId = messageId;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Notes)) {
            return false;
        }
        Notes other = (Notes) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "net.bounceme.dur.usenet.controller.Notes[ id=" + id + " ]";
    }

}

Right now I’m just using the one table, but can’t seem to get a working query.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:01:33+00:00Added an answer on June 3, 2026 at 2:01 pm

    Syntax error parsing the query [Notes.getByIdAndGroup: SELECT DISTINCT n FROM Notes n WHERE n.messageId = :messageId AND n.group=group], line 1, column 74: unexpected token [group].

    In SQL, GROUP is a reserved word, which is probably the reason for this error message. In JPA2 it should be possible to quote the column name in the query by changing the annotation to

    @Column(name="\"GROUP\"")
    

    If that does not work in your case, your best bet would be to change the database column and annotation to something like GROUP_NAME.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe I'm not searching correctly, but I can't find out how to configure the
maybe i am understanding it all wrong but as i understood the best way
Maybe not really big, but a hundred frames or something. Is the only way
Maybe there is a package to do this, but I have not been able
Maybe this question is duplicate, but I can not find an answer for my
Maybe I am not from this planet, but it would seem to me that
Maybe the title of the question is not very self-explanatory but I don't know
Maybe I'm doing something really wrong, but somehow this code always crashes with a
maybe it's dumb but is there a difference between new Something().method(); and Something tmpSomething
Maybe its a very dumb question but I hope you can give me some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.