Revision

  1. Entity States:
  2. Auto Dirty Checking:
  3. Session API:

Any Specific Questions?: Since none were provided, I’ll proceed with the new topics and objectives. If you have questions about entity states, dirty checking, or Session API, please clarify.


New Topics

1. Image Handling

Objective: Store and retrieve user images in/from the database using the FileUtils class from Apache Commons IO, avoiding traditional File I/O methods.

Dependencies: Assume commons-io is in pom.xml:

<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.16.1</version>
</dependency>

User Entity (with image storage):

import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Entity
@Getter
@Setter
@NoArgsConstructor
@ToString(callSuper = true)
public class User extends BaseEntity {
    private String email;
    private String name;

    @Lob // Stores large binary data (BLOB)
    private byte[] profileImage;
}

1.1 Save User Image in DB

1.2 Restore User Image from DB