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 8323909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:52:19+00:00 2026-06-08T23:52:19+00:00

How do I set the parameter for the argument of the query below: entity:

  • 0

How do I set the parameter for the argument of the query below:

entity:

package net.bounceme.dur.usenet.model;

import java.io.Serializable;
import java.util.logging.Logger;
import javax.mail.Folder;
import javax.mail.Message;
import javax.persistence.*;
import net.bounceme.dur.usenet.driver.FetchBean;

@Entity
public class Article implements Serializable {

    private static final long serialVersionUID = 1L;
    private static final Logger LOG = Logger.getLogger(Article.class.getName());
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Column
    private int messageNumber;
    @ManyToOne(cascade = CascadeType.PERSIST)
    private Newsgroup newsgroup;

    public Article() {
    }

    public Article(Message message, Folder folder) {
        messageNumber = message.getMessageNumber();
        EntityManagerFactory emf;
        EntityManager em;
        emf = Persistence.createEntityManagerFactory("USENETPU");
        em = emf.createEntityManager();
        String ng = folder.getFullName();
        Query query = em.createQuery("SELECT n FROM Newsgroup n WHERE n.newsgroup = :newsgroup", Newsgroup.class);
        Newsgroup result = (Newsgroup) query.getSingleResult();
        newsgroup = (result == null) ? new Newsgroup(folder) : result;
    }

    public Long getId() {
        return id;
    }

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

    @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 Article)) {
            return false;
        }
        Article other = (Article) 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 "\nmessageNumber\t" + messageNumber;
    }

    public int getMessageNumber() {
        return messageNumber;
    }

    public void setMessageNumber(int messageNumber) {
        this.messageNumber = messageNumber;
    }
}

Stack trace:

run:
DEBUG: nntp: newsrc loading /home/thufir/.newsrc
DEBUG: nntp: newsrc load: 5 groups in 39ms
[EL Info]: 2012-08-03 03:26:30.737--ServerSession(13970219)--EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
[EL Info]: 2012-08-03 03:26:31.815--ServerSession(13970219)--file:/home/thufir/NetBeansProjects/USENET/build/classes/_USENETPU login successful
Aug 03, 2012 3:26:32 AM net.bounceme.dur.usenet.driver.FetchBean <init>
INFO: [gwene.com.androidcentral, gwene.com.blogspot.emacsworld, gwene.com.blogspot.googlecode, gwene.com.blogspot.googlereader, gwene.com.economist]
Aug 03, 2012 3:26:32 AM net.bounceme.dur.usenet.driver.FetchBean <init>
INFO: Google helping out newcomers with Nexus 7 getting started video
Aug 03, 2012 3:26:33 AM net.bounceme.dur.usenet.driver.FetchBean main
SEVERE: null
java.lang.IllegalStateException: Query argument newsgroup not found in the list of parameters provided during query execution.
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.processParameters(EJBQueryImpl.java:829)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:406)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:773)
    at net.bounceme.dur.usenet.model.Article.<init>(Article.java:34)
    at net.bounceme.dur.usenet.driver.FetchBean.<init>(FetchBean.java:41)
    at net.bounceme.dur.usenet.driver.FetchBean.main(FetchBean.java:21)

BUILD SUCCESSFUL (total time: 13 seconds)

The named parameter should be ng, for newsgroup name, but I can’t seem to get the syntax to query for that string in the Newsgroup.newsgroup field. How do I fix the query?

————-EDIT—————-

new trace:

run:
DEBUG: nntp: newsrc loading /home/thufir/.newsrc
DEBUG: nntp: newsrc load: 5 groups in 30ms
[EL Info]: 2012-08-03 03:57:03.647--ServerSession(33288487)--EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
[EL Info]: 2012-08-03 03:57:04.691--ServerSession(33288487)--file:/home/thufir/NetBeansProjects/USENET/build/classes/_USENETPU login successful
Aug 03, 2012 3:57:05 AM net.bounceme.dur.usenet.driver.FetchBean <init>
INFO: [gwene.com.androidcentral, gwene.com.blogspot.emacsworld, gwene.com.blogspot.googlecode, gwene.com.blogspot.googlereader, gwene.com.economist]
Aug 03, 2012 3:57:05 AM net.bounceme.dur.usenet.driver.FetchBean <init>
INFO: Google helping out newcomers with Nexus 7 getting started video
Aug 03, 2012 3:57:06 AM net.bounceme.dur.usenet.driver.FetchBean main
SEVERE: null
java.lang.IllegalArgumentException: You have attempted to set a parameter value using a name of gwene.com.androidcentral that does not exist in the query string SELECT n FROM Newsgroup n WHERE n.newsgroup = :ng.
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameterInternal(EJBQueryImpl.java:1256)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:1138)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:81)
    at net.bounceme.dur.usenet.model.Article.<init>(Article.java:34)
    at net.bounceme.dur.usenet.driver.FetchBean.<init>(FetchBean.java:41)
    at net.bounceme.dur.usenet.driver.FetchBean.main(FetchBean.java:21)

BUILD SUCCESSFUL (total time: 17 seconds)

code snippet:

String ng = folder.getFullName();
        Query query = em.createQuery("SELECT n FROM Newsgroup n WHERE n.newsgroup = :ng", Newsgroup.class);
        query.setParameter(ng, ng);   //newsgroup object????
        Newsgroup result = (Newsgroup) query.getSingleResult();
        LOG.info(result.toString());
        newsgroup = (result == null) ? new Newsgroup(folder) : result;

I’m playing around with it and will no doubt get it, just need to read the docs and API a bit more, but it’s close enough 🙂

  • 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-08T23:52:21+00:00Added an answer on June 8, 2026 at 11:52 pm
    Query query = em.createQuery("SELECT n FROM Newsgroup n WHERE n.newsgroup = :newsgroup");
    query.setParameter("newsgroup",newsgroup object);
    Newsgroup result = (Newsgroup) query.getSingleResult();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm curious to know what happens if I set the parameter count in cudaMemcpyAsync
I need to write the expression meaning optimize over the parameter set . I
in a method definition why would someone set the formal parameter amount equal to
I am trying to find out how to set the windowless parameter to true,
for String and Object type, I can set the default parameter to null to
I have a sqldatasource connection in whose parameters, the insert parameter is set as
I have a parameter @Department and set its value in the Dataset to =Join(Parameters!Department.Value,,)
How can I set success_url based on a parameter? I really want to go
When I set a default value formula for a date parameter in SSRS, such
I want to set the type of the state parameter, of a state monad

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.