Spring Data JPA Auditing never getting called at runtime - spring-data-jpa

I'm presently struggling with getting Spring Data JPA Auditing to work, it is presently not setting the fields and doesn't seem to be getting called in any way when working with Entities. In particular any insight into how it hooks into the standard flow of persisting Entities would be helpful.
I'm presently using Spring Data JPA 1.5.0.M1 with Spring 3.2.6 and the basic configuration for the auditing piece is:
#Configuration
#EnableJpaAuditing(auditorAwareRef = "auditorAware")
#EnableJpaRepositories(basePackages = "org.myproject.dao")
#EnableTransactionManagement
public class JpaConfig {
...}
the relevant entity at the moment is marked up with the annotations and the interface while trying to work this out (the annotations would be preferred). I realize this should not be done but I copied and pasted for the moment.
#Entity
public class AutoDraft implements Auditable<Long, Long> {
#SequenceGenerator(name="seq_auto_draft", sequenceName="SEQ_AUTO_DRAFT")
#GeneratedValue(strategy=GenerationType.SEQUENCE,generator="seq_auto_draft")
#Id
private Long id;
#CreatedDate
#Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
private DateTime createdDate;
#LastModifiedDate
#Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
private DateTime lastModifiedDate;
In the logs the relevant beans are being set up and I can catch the AuditingHandler being properly configured within the AuditingEntityListener on startup, but nothing seems to be getting triggered at runtime, nor are there any audit related logging messages associated with specific entities or repositories. My attention is presently drawn by the AuditingBeanFactoryPostProcessor, but I've already spent too long on this so could use any assistance.

I know this is an old question, but I hit the same problem and a comment helped me resolve it. So I thought I would make it clearer if anyone falls on this question again.
The documentation for Spring Data is a bit misleading in that it implies that you can enable auditing simply by annotating a #Configuration class with #EnableJpaAuditing.
However, the part I found unclear is that you still need to modify the orm.xml file (https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#auditing):
<persistence-unit-metadata>
<persistence-unit-defaults>
<entity-listeners>
<entity-listener class="….data.jpa.domain.support.AuditingEntityListener" />
</entity-listeners>
</persistence-unit-defaults>
However, if you are using a pure annotation based solution, you may not have an orm.xml file. As indicated by Matt Whipple in a comment, you have to add the #EntityListeners annotation to you entity classes so that the JPA persistence library calks the Spring auditing class when persisting the objects (which in turn deals with the auditing).
So a complete example could be something like:
#Configuration
#EnableJpaAuditing
#PropertySource({ "application.properties" })
public class AppConfig {
/**
* Stubbed method for the auditor as the app does not concern itself with auditing any User fields
* Consequently, return null for the current auditor
* #return
*/
#Bean
public AuditorAware<User> auditorProvider(){
return new AuditorAware<User>() {
#Override
public User getCurrentAuditor() {
return <User object that is Logged In>;
}
};
}
}
Then on your entity:
#Entity
#EntityListeners(AuditingEntityListener.class)
public class Log {
#Id
#GeneratedValue
private long id;
#CreatedDate
#Column(nullable=false)
private Date createdOn;
// bunch of other audit fields (and other fields)
...
...
}

It seems like you forgot to configure AuditingEntityListener in the orm.xml (which is still neccessary). Add this lines to your orm.xml:
<persistence-unit-metadata>
<persistence-unit-defaults>
<entity-listeners>
<entity-listener class="….data.jpa.domain.support.AuditingEntityListener" />
</entity-listeners>
</persistence-unit-defaults>
</persistence-unit-metadata>
see: Spring data jpa documentation: Auditing.

Related

Approve modification on entity before publish

I am trying to create a system that requires an admin to approve a modification to an entity before being published. This system is a REST API with authentication/authorization already working, so that part is not important. Let's assume we have a model depicting an article, with a title and a body. A normal user is allowed to modify all the fields, but before the article is published, it must be approved by an admin. But while the article is in ``approval mode'', the old version of the article must be accessible by the REST API so to at least have a version that works (and the API does not return a 404).
The requirements are:
I am using Spring Data and PostgreSQL so the one that gives me less headaches while integrating it is the one I am going with
The less tinkering with weird checks, the better
If possible, it should be modifiable to be used with other entities
If possible, I would like to keep the old versions and who modified them. Non essential but would be nice
I have two different ideas, but I am not sure which one is the best one:
Create an abstract parent class, and then extend it with an approved and a non-approved version. Then, when the modification is approved the entity is transformed into an approved one and the API will return the new version:
public abstract class Article {}
public class ApprovedArticle extends Article {}
public class ModifiedArticle extends Article {}
Create a separate table where the modified entities are stored, and restrict the view to be admin only. In this case I would isolate the two types and make it easier when fetching info. But I am losing the ``history'' this way and I need to fetch from two different locations.
Simple boolean flag: this is my last resort, and I would love to avoid it!
Is there a better way or should I use one of the outlined examples?
Thanks!
Look into spring Auditing.
https://www.baeldung.com/database-auditing-jpa
So there is an idea:
for each table you have a history table, each history table has REVTYPE( “0” for adding, “1” for updating, “2” for removing an entity) and REV(change number) columns.
Besides these, you need an extra table named REVINFO will be generated by default, to have user details you need to extend default DefaultRevisionEntity class.
#Entity
#RevisionEntity(YOURRevisionListener.class)
#Table(name = "your_audit_info")
#AttributeOverrides(
{#AttributeOverride(name = "timestamp", column = #Column(name = "REVTSTMP")),
#AttributeOverride(name = "id", column = #Column(name = "REV"))})
public class AuditInfo extends DefaultRevisionEntity
{
private static final long serialVersionUID = 8458400378132903089L;
#Column(name = "UpdateUser", nullable = false)
private String userName;
public String getUserName()
{
return userName;
}
public void setUserName(
final String userName)
{
this.userName = userName;
}
}
with audit set up, you get user details if the change approved by admin then compare revisions number when the operation started and operation approved to avoid overwriting by others.
#PrePersist
public void onPrePersist() {
audit("INSERT");
}
#PreUpdate
public void onPreUpdate() {
audit("UPDATE");
}
#PreRemove
public void onPreRemove() {
audit("DELETE");
}
I know it is a very high-level approach, but it can work in your case

GWT Bean validation does not return all constraint violations in compiled mode

I am experiencing different behavior for client side bean validation when running in gwt development mode than in compiled mode. I have been trying to debug and resolve this issue for hours (days actually) but, although further still did not find the root cause and am currently stuck. Hence my request for help.
In general I have been following the approach advocated here http://www.gwtproject.org/doc/latest/DevGuideValidation.html
and was further more inspired by various articles and questions on StackOverlow. So I have the user enter an object on the client. Than I validate it client side via a call to the validator that has been created by the validator factory.
The problem I am experiencing is that when more than one constraint is validated (i.e. the user enters 2 or more "mistakes") the validator does not (always) return all constraint violations when running in compiled mode, while it does return them all when running in gwt development mode.
The object I try to validate is of the class EnvyMonUser
#Entity
public class EnvyMonUser implements Serializable, Obj<EnvyMonUser> {
private static final long serialVersionUID = 3L;
private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*#"
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
#Id
private Long id;
#NotNull(message = "company must be selected")
#Index
private Key<Company> companyKey;
#Index
private String googleUserId;
#NotNull(message = "email address must be set")
#Pattern(regexp = EMAIL_PATTERN, message = "invalid email address")
#Index
private String email;
#NotNull(message = "name must be set")
#Size(min = 3, message = "must have a name of minimal 3 characters")
#Index
private String nickName;
#NotNull(message = "location must be selected")
#Index
private Key<SampleLocation> sampleLocationKey;
#NotNull(message = "result must be set")
#Index
private Long value;
...
Where Company and SampleLocation are two other classes. (The annotations #Entity, #Index, #Id and the class Key are of Objectify. I use the same entity class(es) client and server (gae) side. )
Once the user has entered an EnvyMonUser object I validate it via a validator, i.e.
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
...
EnvyMonUser obj = getView().getEditorDriver().flush();
Set<ConstraintViolation<O>> validate = validator.validate(obj);
where my validation factory is
public final class AppValidatorFactory extends AbstractGwtValidatorFactory {
#GwtValidation(value = { MonitorType.class, Measurement.class,
ProgramMeasurement.class, EnvyMonUser.class, Company.class,
SampleLocation.class })
public interface GwtValidator extends Validator {
}
#Override
public AbstractGwtValidator createValidator() {
return GWT.create(GwtValidator.class);
}
}
Am I doing something wrong?
Desperate as I was I tried removing and adding several fields but have not found any logical pattern. Depending on which fields I leave out and also on which of the fields are filled correctly by the user the (missing) constraint(s) in compiled mode change.
I have already tried multiple routes but no success so far. For example at some point I thought this was caused by using objectify. However when I remove sampleLocationKey member it works perfectly fine for companyKey member. I also tried removing the objectify attributes but this also doesn't seem to make a difference.
An interesting thing I did observe (by accident) is that when I remove (comment) some of the members from the hashCode and equals methods the behavior changes. Not sure why this is. Maybe it has something to do with how the validator generator is implemented.
Does anyone have any clue?
Also a pointer in the right direction is appreciated. Does someone for example know where I can find the validator that is generated. Or the sources of the validator generator?
Some versions of libraries I use:
gwt 2.6.0
hibernate-validator-4.1.0.Final.jar
hibernate-validator-4.1.0.Final-sources.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
log4j-1.2.16.jar
objectify 4.0.1
Turns out the problem was not in my code but a bug in gwt sources for com.google.gwt.validation.client.impl.ConstraintViolationImpl . See https://groups.google.com/forum/#!topic/Google-Web-Toolkit/xRVGnMWfttc for a full description of the problem and solution.
I had the same issue. The validations were working fine on dev mode and all the error messages were showing up on the UI but in the prod mode we could see only one error message at one time. Late on when debugged and found that my DTO has implemented equals and hashcode method and that what causing this issue. The moment is removed these two implementations from my DTO every things worked fine after that.
I am using GWT 2.6.1.

How to avoid lazy loading in play framework

In play framework, I use following code to fetch values from a table called "Report" which has other relationship tables like "Project","Build" etc.
List<Report> rpts = Report.find.where()
.eq("publish","1")
.eq("functionality_id", Integer.toString(fun.id))
.eq("project_id", currentProject.id)
.eq("prod_build", prod_build)
.eq("loadType_id", loadType_id)
.in("build_id", buildId)
.orderBy("id desc")
.findList();
I get list of values from "Report" table, but all related table values are not populated. They are populated with null.
#Entity
#Table(name="report")
public class Report {
#Id
public int id;
#Constraints.Required
#ManyToOne
#JoinColumn(name="build_id")
public Build build;
#Constraints.Required
#ManyToOne
#JoinColumn(name="project_id")
public Project project;
.
.
}
It was loaded with those values when I tested couple of days ago, but not working today. When I do rpts.get(i).build.release , it gives nullPointerException because build is null here. This code has not been changed in recent days. Wondering why this is happening. Can someone suggest me whether there is any other setting file (like application.conf) that does this lazy loading. Please help.
I've resolved it.
The problem is that I created an Ebean transaction using following code that caused the trouble.
Ebean.beginTransaction();
try{
group.role = "A";
Ebean.update(group);
Ebean.commitTransaction();
} finally {
Ebean.endTransaction();
}
I never suspected that this could would have caused the problem as I put this code in another class file that is not related to this page. Then I changed to following code and everything worked as expected.
#Transactional
public void saveGroup(Group group){
group.role = "A";
Ebean.save(group);
.
.
}
Following documentation in play framework site helped me to identify the culprit. :)
Enhancement of direct Ebean field access (enabling lazy loading) is
only applied to Java classes, not to Scala. Thus, direct field access
from Scala source files (including standard Play 2 templates) does not
invoke lazy loading, often resulting in empty (unpopulated) entity
fields. To ensure the fields get populated, either (a) manually create
getter/setters and call them instead, or (b) ensure the entity is
fully populated before accessing the fields.

jpa error uses a non-entity [class ch.printsoft.mailhouse.usermgr.entity.Department] as target entity in the relationship attribute

I try to persist my Department and Mandator classes to hsqhldb but it gives this error.
Exception Description: [class ch.printsoft.mailhouse.usermgr.entity.Mandator] uses a non-entity [class ch.printsoft.mailhouse.usermgr.entity.Department] as target entity in the relationship attribute [field departments].
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:115)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
These are the classes that I try to persist to my database. I really don't know what the problem is.
#Entity
public class Mandator {
#Id
#GeneratedValue
private Integer id;
private String mandatorId;
#OneToMany(mappedBy = "mandator")
private List<MandatorUser> mandatorUsers;
#OneToMany(mappedBy = "mandator")
private List<SLAFamilyGroup> slaFamilyGroups;
#OneToMany(mappedBy = "mandator")
private List<Group> groups;
#OneToMany(mappedBy = "mandator")
private List<Department> departments;
#OneToMany(mappedBy = "mandator")
private List<CostUnit> costUnits;
#Entity
public class Department {
#Id
#GeneratedValue
private Integer id;
private String name;
private String responsiblePerson;
private String location;
#ManyToOne(optional = false)
private Mandator mandator;
#ManyToMany
private List<DocumentUser> documentUsers;
I've really tried every thing but it didn't work.
I just spent a lot of time debugging a seemingly unexplainable case of this exception, so I'm just leaving my story here.
If you're using a somewhat old implementation of JPA (e.g. EclipseLink 2.5.x) and you're using modern Java 8 features (such as lambda expressions) in your code base - don't ever use them in the JPA entity classes.
EclipseLink 2.5's class metadata parser crashes upon encountering Java 8 features (such as lambda expressions, method references etc.) in the bytecode. The internal crash is a very unfriendly ArrayIndexOutOfBoundsException, but you don't even get to see it, as the weaver code silently ignores metadata parser crashes and just assumes the class has no interesting metadata. This leads it to believe that the class in question is not an entity even though it has all the proper annotations, and the end result is the error message we are talking about.
Bottom line: Don't use Java 8 lambdas in JPA entity classes. EVER.
Ensure you have both classes listed in your persistence.xml, and the both classes are on the classpath.
Please include your persistence.xml.
I hope this can help someone.
I had the same problem.
The night before, everything was ok.
In NetBeans I've checked, using History, all the files involved in the error.
Persistence.xml included.
Nothing was changed.
I've checked also manually.
I've tryed all the solution suggested in this thread even migrate to eclipselink 2.6.4.
I've removed the 2 class involved in the persistence.xml, saved it, and added again.
The error was still there.
Then, I've removed ALL the classess in the list of the Entity Classes included in the persistence.xml, and then I've included them again.
Now it works.
Magically.
But really there were non difference in the history.
Even a single character.
Ensure you have defined both classes are under < persistence-unit > tag of persistence.xml file. As we know At the time of persistence the entity into DB. Our Application finds the entity classes information from persistence.xml file. If entity's mapping is not found in persistence.xml, then application throw this exception while you will perform any operation on that entity like here your are.
So Please make both entities entry in your persistence.xml
Example:
persistence.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="mapping_unit">
<class>ch.printsoft.mailhouse.usermgr.entity.Mandator </class>
<class>ch.printsoft.mailhouse.usermgr.entity.Department</class>
...
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/practice" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
<property name="eclipselink.logging.level" value="SEVERE" />
<property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
</properties>
</persistence-unit>
</persistence>
Remove mappedBy from #OneToMany annotations from Mandator class
Check if all related classes are mapped as #Entity. Department class has #ManyToMany relation to DocumentUser. Provide the listing of DocumentUser class
Make sure that both "class" files are in the same jar.
Make sure that you don't have two .class files with the same name !
Ensure you have both classes has the property of PK and the no parameter constructor.
I add the following code in my entity class.
#Entity
public class EntityClass{
#Id
#GeneratedValue(strategy=GenerationType.AUTO)
public int id;
public EntityClass() {
}
...
}
Examine your mappedBy=xxx and make sure xxx is unique in whole project.
1))Proper relationship for the parent and child.
First Class
#Entity
#Table(name="nova_payment_result")
#NamedQuery(name="NovaPaymentResult.findAll", query="SELECT n FROM NovaPaymentResult n")
#JsonIgnoreProperties({"novaOrder"})
public class NovaPaymentResult implements Serializable {
private static final long serialVersionUID = 1L;
//bi-directional many-to-one association to NovaOrder
#JsonIgnoreProperties("paymentResults")
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name="orderid")
private NovaOrder novaOrder;
2nd class
#Entity
#Table(name="nova_order")
#NamedQueries({
#NamedQuery(name="NovaOrder.findAll", query="SELECT n FROM NovaOrder n")
})
#JsonIgnoreProperties({"novaOrders","novaCustomerProfile"})
public class NovaOrder implements Serializable {
private static final long serialVersionUID = 1L;
#OneToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL,mappedBy="novaOrder")
private List<NovaPaymentResult> paymentResults;
Makesure entery in persistence.xml should be there for both classes.
What a nightmare. For me it worked when I invalidated the caches of IntelliJ Idea from the File menu

Seam 2.2 with jboss 5 non ejb can't inject entityManager

ETA an explanation of what this is supposed to do.
An employee has to keep track of 2 weeks worth of activities.
Each week(tqiActivitySheetActionBean) contains 7 days (tqiDayActionBean).
Each day contains tasks for that day(tqiTasks)
Tasks are displayed one week at a time(so the employee can switch between this week and last week).
What I did was use an enum to iterate over the week - creates a dataTable of tqiActivitySheetActionBeans and iterate over those in a nested dataTable.
The employee needs to be able to add, delete and edit tasks for each day in place(in the dataTable). I wrapped the tqiTasks in the tqiDayActionBean to group them.
I posted this over at the Seam website, but I'm not getting any bites, I've tried everything I know and some stuff I don't to get this working, but so far no joy.
There's configuration information for Jboss 5 using EJB's, Jboss 4 without. I have an exploded WAR using Jboss 5 and Seam 2.2.0, and no EJB's. I cannot inject an entityManager into my action POJOs.
I tried removing the persistence-unit-ref-name reference from web.xml, added and removed
<transaction:entity-transaction />
<transaction:ejb-transaction />
tags from components.xml (with and without entity-manager="#{entityManager}") . The app won't load when I use either of these.
Used the default values and hardcoded them one at a time. I still can't get this to work.
I'm currently using this configuration:
persistence.xml:
<persistence-unit name="myEmployee" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/myEmployeeDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.default_schema" value="MY_PROD"/>
<!-- Only relevant if Seam is loading the persistence unit (Java SE bootstrap) -->
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
<!-- this binds emf to jndi under java namespace - but only for jboss prior to 5.0 - I shouldn't need this. -->
<property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManagerFactories/myEmployee"/>
</properties>
</persistence-unit>
components.xml:
<persistence:managed-persistence-context name="entityManager"
persistence-unit-jndi-name="java:/EntityManagerFactories/myEmployee"
auto-create="true"/>
This deploys and starts correctly, but entityManager is still null.
I have a bunch of EntityHome classes in the same package, these can use an entityManager with no problem. All the docs I've looked at state that I should be able to inject an entityManager, I've followed the configuration info from the Seam docs page, the Seam in Action book and the Seam wiki for JBoss 5 (Seam wiki)
I've set breakpoints in the ManagedPersistence class - where it looks like I have an entityManager right up to the time I want to use it, added #Transactional annotations to the class and method. Still nothing. I can get an EM using
(EntityManager)Component.getInstance("entityManager")
But then I have no transactional access to the underlying entityBean and end up with hibernate LazyInitializationExceptions.
I've been using Seam for almost a year now and I have yet to get this to work. Up til now using the Component method has worked, but There must be something fundamentally wrong with our setup that I cannot get injection to work.
I'd appreciate any help.
ETA code for user classes.
The entity class is TQITask. TQIDayActionBean class is supposed to handle the CRUD for a group of TQITasks for one day, TQIActivitySheetActionBean handles the TQIDayActionBeans for one week.
entity bean:
#Entity
#Table(name = "TQI_TASK")
#Name("tqitask")
public class TqiTask implements java.io.Serializable {
static Logger log = Logger.getLogger(TqiTask.class);
private Integer sysid;
private TqiActivitySubtype tqiActivitySubtype;
private TqiActivityType tqiActivityType;
// ... more fields, getters and setters
dayActionBean(a days tasks):
#Name("tQIDayActionBean")
#Transactional(TransactionPropagationType.REQUIRED) //this is latest attempt
#Scope(ScopeType.CONVERSATION)
public class TQIDayActionBean implements Serializable {
static Logger log = Logger.getLogger(TQIDayActionBean.class);
#In(required=true)
EntityManager entityManager;
//this doesn't work either
#DataModel("tqiTasksForOneDay")
#Out(required = false)
private List<TqiTask> tqiTasksForOneDay;
// .... more stuff
// method that should get an entityManager
/**
* tasks are children of tqiActivitySheet, info we need is in tqiActivitySheetV, so use peopleSoftIdSelected and weekSelected.weekSysid
* to get the tqiActivitySheet sysid needed to load the right tasks
* TODO for now lets just get it straight from the db
*/
#SuppressWarnings("unchecked")
#Begin(flushMode=FlushModeType.MANUAL)
public void generateTasksForDayOfWeek() {
log.debug("date to search for: " + this.tqiTaskDate);
this.tqiTasksForOneDay = this.entityManager.createQuery("SELECT t from TqiTask t where t.workDate = ?1 AND t.activitySheetSysid = ?2 order by t.sysid")
.setParameter(1, this.tqiTaskDate).setParameter(2, this.activitySheetSysid).getResultList();
}
getter/setters etc ...
activitySheetActionBean(a week's dayActionBeans):
/**
* handle the activity sheet weekly code generation here
*/
#Name("tqiActivitySheetActionBean")
public class TQIActivitySheetActionBean implements Serializable{
static Logger log = Logger.getLogger(TQIActivitySheetActionBean.class);
// tried it here first
// #In
// EntityManager entityManager;
#Out(value="tqiDayActionBeansForTheWeek", required=false)
List<TQIDayActionBean> tqiDayActionBeansForTheWeek;
// List<DaysOfTheWeek> daysOfTheWeekEnum;
private BigDecimal currentlySelectedWeekActivitySheetSysid;
#PostConstruct
public void init(){
log.debug("calling init");
this.tqiDayActionBeansForTheWeek = new ArrayList<TQIDayActionBean>();
this.updateDataWhenWeekChanges();
}
getters/setters more stuff ....
The bean named tQIDayActionBean of class TQIDayActionBean cannot be instantiated with new, and there is absolute no way to have a List<TQIDayActionBean> in the application.
This bean, like any other Seam managed bean, can only be injected with #In or instantiated with Component.getInstance(). In the second case (that is with Component.getInstance()) you should understand that Seam will always return the same instance as far as you stay in the context boundaries (in this case until the conversation ends).
I suggest that you rework your code in order to separate a TQIDay standard class (without #Name and #Inject) to model the data you need to manage and collect in multiple instances, from an TQIActionBean where you can have your EntityManager injected.