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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:59:07+00:00 2026-06-10T16:59:07+00:00

Short Description of the problem: I generate a file inside the entity class and

  • 0

Short Description of the problem:
I generate a file inside the entity class and would like to save the filename to the database. The controller doesn’t know about this (wheter or not the filename has changed, so it’s not practical to persist from the controller.

Is there a way for an Entity to persist itself?

Example of my use:
The entity class is for an image in a gallery. I always keep the original file and work with a cached version of the file. When the image is changed (rotated for example), the cached version is deleted. The cached version also be deleted in other cases. When the file is needed, I check if the cached file exists, otherwise it is regenerated with a new filename from the archived image. I need a new filename because that resets the cache for various thumbnail sizes.

When I generate that new file, I have to save its filename to the database somehow. Because it is only decided in the Entity when to regenerate the image, it would be practical if the entity could persist itself to the database, but I haven’t found a solution for that.

Is there a way to do this or is there a whole different concept I should be using to regenerate the image file?

  • 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-10T16:59:09+00:00Added an answer on June 10, 2026 at 4:59 pm

    Entities in Doctrine are not active records – they cannot perform persistance actions by themselves, so they rely on a Big Brother [the entity manager].

    Even if the controller doesn’t know wether any filename as changed or not, you do – just persist your picture every time: if nothing changed, Doctrine won’t touch the entity.

    Have a look at lifecycle events too, maybe you can find useful to fire a @PreUpdate method before persistance [e.g. generating thumbnails].

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

Sidebar

Related Questions

My problem is: I would like to get all advertistments where id of Description
SHORT DESCRIPTION OF PROBLEM: I want to set the text of a searchbar without
Short problem description: XCode 4.2 install right Target on device, but debug (run) always
I need to display short description like label and near it data associated with
I have a search result like 1. my title my short description...... http://www.stackoverflow.com/tags/thisthat/againthisthat/againandagainthisthat/mypage.html http://www.stackoverflow.com/tags/mypage.html?a=123123123&b=2342343
First, a short description of the problem's background: I've run into troubles with handling
First - a short description of a problem. I write a JavaScript function to
Short description of my problem: I start up Tomcat with my deployed Wicket application.
Short description of my setup: There is an SQLObject base class which has an
Firstly a short description of what I have Images of the same size and

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.