Kari5
Kari5

Reputation: 188

JPA Entity static logger

My question is, can i use a static logger in a JPA Entity, or will it cause some problem? I would like to do something like this (the logger is log4j):

    @Entity
public class AlertRule implements Serializable {
/**
 * Serial version ID.
 */
private static final long serialVersionUID = 9000392523924653431L;

/**Logger. */
transient private static final Logger LOGGER = Logger.getLogger(AlertRule.class);

/**
 * ID.
 */
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;

/**
 * Rule name.
 */
@NotNull
private String name;

...

Upvotes: 5

Views: 2308

Answers (1)

DataNucleus
DataNucleus

Reputation: 15577

With standard JPA, static fields are not persisted, and final fields are not persisted, so its not a problem

Upvotes: 7

Related Questions