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

  • Home
  • SEARCH
  • 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 328079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:27:42+00:00 2026-05-12T09:27:42+00:00

I have this entity class, called Pagina and I want to update the entry

  • 0

I have this entity class, called “Pagina” and I want to update the entry in the database based on the changes made to the entity. This isn’t working. I get no errors, but the db is not changed.

@Entity
@Table(name = "PAGINA")
@NamedQueries({@NamedQuery(name = "Pagina.findAll", query = "SELECT p FROM Pagina p"), 
@NamedQuery(name = "Pagina.findHashByURL", query= "SELECT p.chash FROM Pagina p WHERE p.url = :url"),
@NamedQuery(name = "Pagina.findTimestampByURL", query= "SELECT p.timestamp FROM Pagina p WHERE p.url = :url"),
@NamedQuery(name = "Pagina.findByUrl", query = "SELECT p FROM Pagina p WHERE p.url = :url"),
@NamedQuery(name = "Pagina.findByProfondita", query = "SELECT p FROM Pagina p WHERE p.profondita = :profondita"),
@NamedQuery(name = "Pagina.findByIntervallo", query = "SELECT p FROM Pagina p WHERE p.intervallo = :intervallo"),
@NamedQuery(name = "Pagina.findByTimestamp", query = "SELECT p FROM Pagina p WHERE p.timestamp = :timestamp"), 
@NamedQuery(name="Pagina.findAllURL", query="SELECT p.url FROM Pagina p"),
@NamedQuery(name="Pagina.findDelayByURL", query="SELECT p.intervallo FROM Pagina p WHERE p.url = :url"),
@NamedQuery(name = "Pagina.findByUpdated", query = "SELECT p FROM Pagina p WHERE p.updated = :updated")})
public class Pagina implements Serializable, Delayed{
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "URL")
    private String url;
    @Column(name = "PROFONDITA")
    private Integer profondita;
    @Column(name = "INTERVALLO")
    private Integer intervallo;
    @Lob
    @Column(name = "CHASH")
    private String chash;
    @Column(name = "TIMESTAMP")
    private Integer timestamp;
    @Column(name = "UPDATED")
    private Boolean updated;


[cut]

In another class I retrieve the objects stored in the database (mysql) using a methods defined in a class that contains methods that work on the entity. This method use the query “findAll”. The method’s code is the following:

public List<Pagina> findAll(){
EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("CrawlerPU");
        EntityManager em = emf.createEntityManager();  
List o = (List) em.createNamedQuery("Pagina.findAll").getResultList();
        return o;
    }

I’m using this method as you can see in the code:

 PaginaMethods p = new PaginaMethods();

        List<Pagina> l = p.findAll();
   while (it.hasNext()) {
            Pagina s = (Pagina) it.next();
            s.setUpdated(Boolean.TRUE);

If I watch the db, nothing has changed after this operations. My persistence.xml has the entry ” ”
Can you help me? I don’t know how to solve this… I can change things if needed.

  • 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-05-12T09:27:42+00:00Added an answer on May 12, 2026 at 9:27 am

    Think of Hibernate as a big cache that can use a DB as a “store” where it puts things that don’t fit into the cache anymore. Hibernate will not flush everything to the DB as you change it, it will wait. Chances are that you might change more than a single field in an object.

    So you need to flush the session (em.flush()), or you must run a query, or you must commit the current transaction (not an easy option when using Spring).

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

Sidebar

Related Questions

I have this Entity called 'Operation': @Entity @Table(name=operation) public class Operation implements Serializable {
I have an entity called Account and I have given this entity a class
If I have this entity: @Entity class Pet { @Id long id; public enum
Let's say I have this entity (for Hibernate): @Entity public class Person { @Id
I have a Customer class defined like this: @Entity public class Customer { //...
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A
I have this piece of code: @Entity @Table(name = MOVERS) public class MOVers implements
I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
I have a Person and an Organisation Entity: Person looks like this: public class
I have a class called Entity, with two child classes: Creature and Item. (I'm

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.