# Hibernate - Save Child wenn nötig



## Moinsn (21. Okt 2013)

Hallo,

ich habe folgende Struktur:



```
@Entity
@Table(name = "trips")
@SessionScoped
public class TripEntity extends BaseEntity {
	private static final long serialVersionUID = -2482575248037071596L;

	@ManyToOne(targetEntity = TrackEntity.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL, optional=false)
	@JoinColumn(name = "track_id", referencedColumnName="id")
	private TrackEntity track;
.
.
.
}
```


```
@Entity
@Table(name = "tracks", uniqueConstraints = @UniqueConstraint(columnNames = { "city1_id", "city2_id" }))
@SessionScoped
public class TrackEntity extends BaseEntity {
	private static final long serialVersionUID = 4696847902782174082L;

	@ManyToOne(targetEntity = CityEntity.class, fetch = FetchType.EAGER, cascade = CascadeType.PERSIST, optional=false)
	@JoinColumn(name="city1_id")
	private CityEntity city1;
	
	@ManyToOne(targetEntity = CityEntity.class, fetch = FetchType.EAGER, cascade = CascadeType.PERSIST, optional=false)
	@JoinColumn(name="city2_id", referencedColumnName="id")
	private CityEntity city2;
	
	private Integer distance;
.
.
.
}
```


```
@Entity
@Table(name = "cities")
@SessionScoped
public class CityEntity extends BaseEntity {
	private static final long serialVersionUID = 8823384603378561475L;
	
	private String name;
	@Column(unique=true)
	private String zipcode;
.
.
.
}
```

Mögliche UseCases:
1. City1 & City2 noch nicht persistiert -> muss also beim speichern eines Trips relational gespeichert werden
2. City1 oder City2 noch nicht persistiert -> eine der beiden wurde also schon vorher aus der DB geladen und besitzt eine id. Diese id muss als fremdschlüssel gespeichert werden, die noch nicht persistierte City muss relational gespeichert werden.
3. City1 & City2 schon persistiert (ids schon in DB und Objekt vorhanden) -> fremdschmuss also beim speichern eines Trips gespeichert werden

Beim speichern eines trips bekomme ich derzeit die Meldung "cityId can not be null"
Beim speichern eines tracks hatte es glaube ich funktioniert ....
(Kann ich im moment nicht testen da noch kein jUnit implementiert / Test durch frontend nur möglich wenn schon ein trip in DB)

Sollte Hibernate solche Sachen wie City schon in DB / City noch nicht in DB nicht in default config schon richtig auflösen?

DANKE


----------



## KSG9|sebastian (25. Okt 2013)

Vermutlich hast du keinen Generator für die ID von BaseEntity angegeben - dadurch meckert Hibernate zu recht, dass das Objekt beim persistieren eine ID haben muss.

Warum eigentlich @SessionScoped???


----------



## Moinsn (25. Okt 2013)

Ahhh,

ich glaube du hast mich da auf etwas gebracht.
Die Basisklasse meiner Pojos habe ich vor einer ganzen weile hinzugefügt und erst durch deinen Tipp ein altes TODO gefunden.

hier der code:


```
@MappedSuperclass
public class BaseEntity implements Serializable {
	
//	TODO: Chance GeneratedValue cause it dosent works with mySQL
	@Id
	@GeneratedValue
	private Long id;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

}
```

könnte das der Grund dafür sein dass es Hibernate nicht hin bekommt, ein Objekt mit einem schon in der DB vorhandenen Child und einem weiteren relational zu speichernden child zu persistieren?
PS: Komischer weise funktioniert das auto increment auf der id mit mySql wunderbar!? 

zum Thema SessionScoped muss ich zugeben grade überfragt zu sein.
Check gleich mal wie sich die Anwendung ohne diese Annotation verhält.


----------



## KSG9|sebastian (25. Okt 2013)

Da du AutoIncrement verwenden willst foglendes (geht definitiv mit MySQL)


```
@MappedSuperclass
public class BaseEntity implements Serializable {
    
//  TODO: Chance GeneratedValue cause it dosent works with mySQL
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
 
    public Long getId() {
        return id;
    }
 
    public void setId(Long id) {
        this.id = id;
    }
 
}
```

Zeig mal den Code den du zum speichern verwendest. Hibernate hat definitiv kein Problem damit eine persistente Entität mit einer transienten Referenz zu speichern...


----------



## Moinsn (25. Okt 2013)

Ursprünglich sollte die save des genericDao reichen.


```
public T save(T entity) {
		getEntityManager().persist(entity);
		return entity;
	}
```

Als ich feststellte dass ich, sobald city1 in DB und Objekt mit id vorhanden & city2 noch zu persistieren, eine Duplicate entity exception bekomme, habe ich die save überschrieben.


```
@Override
	@Transactional
	public TrackEntity save(TrackEntity track) {

		if (track.getId() == null) {
			if (track.getCity1().getId() == null) {
					cityDao.save(track.getCity1());
			}

			if (track.getCity2().getId() == null) {
					cityDao.save(track.getCity2());
			}

			if(track.getDistance() != null) {
				super.save(track);

				super.flush();
			}

			return track;
		} else {
			return track;
		}
	}
```

Letzteres sollte jedoch meines Verständnisses nach nicht notwendig sein.


----------



## KSG9|sebastian (25. Okt 2013)

Die Fehlermeldung mit "..id cannot be null" heißt das Hibernate erwartet das der PrimaryKey schon gesetzt ist. Und das ist der Fall wenn du keinen Generator für die ID hast und die ID auch nicht manuell setzt.

Generator auf AUTO stellen, dann sollte es auch funktionieren.

Falls nicht bitte mal sämtliche Entitys posten und den dazugehörigen Business-Code, einschließlich Infos zu Transaktionen u.s.w.


----------



## Moinsn (25. Okt 2013)

Also,
im Moment funktioniert nicht einmal mehr der Standardfall.

Der Ausgangszustandist eine leere DB. -> Unique constraints können nicht verletzt werden.

Pojos sehen folgendermaßen aus:

TripEntity

```
@Entity
@Table(name = "trips")
//@SessionScoped
public class TripEntity extends BaseEntity {
	private static final long serialVersionUID = -2482575248037071596L;

	@ManyToOne(targetEntity = TrackEntity.class, fetch = FetchType.EAGER, cascade = CascadeType.PERSIST, optional=false)
	@JoinColumn(name = "track_id", referencedColumnName="id")
	private TrackEntity track;

	@Column(name = "tripdate", columnDefinition = "DATETIME")
	@Temporal(TemporalType.TIMESTAMP)
	private Date tripDate;

	private Integer maxIndirection;

	private String state;
	private Long userId;
	private Long shippingAgencyId;

	//DefaultConstructor not possible?
	
	private String customerName;
	private String customerMail;
	private String customerTelephone;
	private String customerStreet;
	private String customerCity;
	private String customerZip;

	private String contractStreet;
	private String contractCity;
	private String contractZip;

	private String contractObjectWidth;
	private String contractObjectLength;
	private String contractObjectHeight;
	private String contractParticularities; // (Besonderheiten)

	@Transient
	private ShippingAgencyEntity shippingAgency;
	@Transient
	private double price;
	@Transient
	private Integer calcIndirection;
	@Transient
	private Date contractArrivalTime;

getter, setter, eqals & toString
.......
	
	
}
```

TrackEntity

```
@Entity
@Table(name = "tracks", uniqueConstraints = @UniqueConstraint(columnNames = { "city1_id", "city2_id" }))
//@SessionScoped
public class TrackEntity extends BaseEntity {
	private static final long serialVersionUID = 4696847902782174082L;

	@ManyToOne(targetEntity = CityEntity.class, fetch = FetchType.EAGER, optional=false) //cascade = CascadeType.REFRESH, 
	@JoinColumn(name="city1_id")
	private CityEntity city1;
	
	@ManyToOne(targetEntity = CityEntity.class, fetch = FetchType.EAGER, optional=false) //cascade = CascadeType.PERSIST, 
	@JoinColumn(name="city2_id") //, referencedColumnName="id"
	private CityEntity city2;
	
	private Integer distance;
	
	//DefaultConstructor not possible?


......
}
```

CityEntity

```
@Entity
@Table(name = "cities")
//@SessionScoped
public class CityEntity extends BaseEntity {
	private static final long serialVersionUID = 8823384603378561475L;
	
	private String name;
	@Column(unique=true)
	private String zipcode;
	private String latitude;
	private String longitude;
	
	//DefaultConstructor not possible?
	
....
	
}
```

BaseEntity

```
@MappedSuperclass
public class BaseEntity implements Serializable {
	
//	TODO: Chance GeneratedValue cause it dosent works with mySQL
	@Id
	@GeneratedValue
	private Long id;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

}
```

Debug zeigt ein 
Trip Objekt (id = null)
 das beinhaltet ein Track Objekt (id = null)
    das wiederum City Objekte auf city1 und city2 beinhaltet (id überall = null)

damit rufe ich die save Methode meines GenericDao auf


```
@Transactional
public abstract class GenericJpaDao<T, ID extends Serializable> implements
		GenericDao<T, ID> {

	private Class<T> persistentClass;

	private EntityManager entityManager;

	public GenericJpaDao(Class<T> persistentClass) {
		this.persistentClass = persistentClass;
	}

	protected EntityManager getEntityManager() {
		return entityManager;
	}

	@PersistenceContext
	public void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}

	public Class<T> getPersistentClass() {
		return persistentClass;
	}

	@Transactional(readOnly = true)
	public T findById(ID id) {
		T entity = (T) getEntityManager().find(getPersistentClass(), id);
		return entity;
	}

	@SuppressWarnings("unchecked")
	@Transactional(readOnly = true)
	public List<T> findAll() {
		return getEntityManager().createQuery(
				"select x from " + getPersistentClass().getSimpleName() + " x")
				.getResultList();
	}

	public T save(T entity) {
		getEntityManager().persist(entity);
		return entity;
	}

	public T update(T entity) {
		T mergedEntity = getEntityManager().merge(entity);
		return mergedEntity;
	}

	public void delete(T entity) {
		if (BaseEntity.class.isAssignableFrom(persistentClass)) {
			getEntityManager().remove(
					getEntityManager().getReference(entity.getClass(),
							((BaseEntity) entity).getId()));
		} else {
			entity = getEntityManager().merge(entity);
			getEntityManager().remove(entity);
		}
	}

	public void flush() {
		getEntityManager().flush();
	}

}
```


----------



## Moinsn (25. Okt 2013)

Exception

```
18:21:07,064 DEBUG AnnotationTransactionAttributeSource:106 - Adding transactional method 'save' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
18:21:07,075  WARN UnresolvedEntityInsertActions:163 - HHH000437: Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity. The unsaved transient entity must be saved in an operation prior to saving these dependent entities.
	Unsaved transient entity: ([de.wiegand.mytransport.domain.TrackEntity#<null>])
	Dependent entities: ([[de.wiegand.mytransport.domain.TripEntity#<null>]])
	Non-nullable association(s): ([de.wiegand.mytransport.domain.TripEntity.track])
18:21:07,076  WARN UnresolvedEntityInsertActions:163 - HHH000437: Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity. The unsaved transient entity must be saved in an operation prior to saving these dependent entities.
	Unsaved transient entity: ([de.wiegand.mytransport.domain.CityEntity#<null>])
	Dependent entities: ([[de.wiegand.mytransport.domain.TrackEntity#<null>]])
	Non-nullable association(s): ([de.wiegand.mytransport.domain.TrackEntity.city1])
18:21:07,076  WARN UnresolvedEntityInsertActions:163 - HHH000437: Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity. The unsaved transient entity must be saved in an operation prior to saving these dependent entities.
	Unsaved transient entity: ([de.wiegand.mytransport.domain.CityEntity#<null>])
	Dependent entities: ([[de.wiegand.mytransport.domain.TrackEntity#<null>]])
	Non-nullable association(s): ([de.wiegand.mytransport.domain.TrackEntity.city2])
18:21:07,079 DEBUG DefaultMessageContext:120 - Resolving message using [FlowFacesContextMessageDelegate.FlowFacesMessageAdapter@56c4ea0e severity = INFO, text = 'org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation: de.wiegand.mytransport.domain.TrackEntity.city1 -> de.wiegand.mytransport.domain.CityEntity']
18:21:07,080 DEBUG DefaultMessageContext:125 - Adding resolved message [FlowFacesContextMessageDelegate.FlowFacesMessageAdapter@56c4ea0e severity = INFO, text = 'org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation: de.wiegand.mytransport.domain.TrackEntity.city1 -> de.wiegand.mytransport.domain.CityEntity']
18:21:07,080 DEBUG DefaultMessageContext:120 - Resolving message using [FlowFacesContextMessageDelegate.FlowFacesMessageAdapter@5f85599b severity = INFO, text = 'org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation: de.wiegand.mytransport.domain.TrackEntity.city1 -> de.wiegand.mytransport.domain.CityEntity']
18:21:07,081 DEBUG DefaultMessageContext:125 - Adding resolved message [FlowFacesContextMessageDelegate.FlowFacesMessageAdapter@5f85599b severity = INFO, text = 'org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation: de.wiegand.mytransport.domain.TrackEntity.city1 -> de.wiegand.mytransport.domain.CityEntity']
java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation: de.wiegand.mytransport.domain.TrackEntity.city1 -> de.wiegand.mytransport.domain.CityEntity
18:21:07,084 DEBUG AnnotatedAction:149 - Clearing action execution attributes map[[empty]]
18:21:07,084 DEBUG FlowExecutionImpl:590 - Attempting to handle [org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@46f9030c targetAction = [EvaluateAction@7fb98d75 expression = tripService.addTrip(newTrip), resultExpression = [null]], attributes = map[[empty]]] in state 'addTrip' of flow 'account' -- action execution attributes were 'map[[empty]]'] with root cause [javax.persistence.RollbackException: Transaction marked as rollbackOnly]
18:21:07,084 DEBUG FlowExecutionImpl:611 - Rethrowing unhandled flow execution exception
18:21:07,085 DEBUG SessionBindingConversationManager:99 - Unlocking conversation 2
18:21:07,088 ERROR AnnotationMethodHandlerExceptionResolver:143 - Invoking request method resulted in exception : public static native long java.lang.System.currentTimeMillis()
java.lang.IllegalArgumentException: Invalid handler method return value: 1382718067086
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver.getModelAndView(AnnotationMethodHandlerExceptionResolver.java:410)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver.doResolveException(AnnotationMethodHandlerExceptionResolver.java:140)
	at org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:136)
	at org.springframework.web.servlet.DispatcherServlet.processHandlerException(DispatcherServlet.java:1120)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:944)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1329)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.[url]www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150[/url])
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:445)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:556)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1038)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:374)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:972)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:363)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:483)
	at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:931)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:992)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
	at java.lang.Thread.run(Thread.java:722)
2013-10-25 18:21:07.091:WARN:oejs.ServletHandler:/app/account
org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@46f9030c targetAction = [EvaluateAction@7fb98d75 expression = tripService.addTrip(newTrip), resultExpression = [null]], attributes = map[[empty]]] in state 'addTrip' of flow 'account' -- action execution attributes were 'map[[empty]]'
	at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:60)
	at org.springframework.webflow.engine.support.ActionTransitionCriteria.test(ActionTransitionCriteria.java:82)
	at org.springframework.webflow.engine.support.TransitionCriteriaChain.test(TransitionCriteriaChain.java:71)
	at org.springframework.webflow.engine.Transition.canExecute(Transition.java:195)
	at org.springframework.webflow.engine.Transition.execute(Transition.java:211)
	at org.springframework.webflow.engine.impl.FlowExecutionImpl.execute(FlowExecutionImpl.java:393)
	at org.springframework.webflow.engine.impl.RequestControlContextImpl.execute(RequestControlContextImpl.java:214)
	at org.springframework.webflow.engine.TransitionableState.handleEvent(TransitionableState.java:119)
	at org.springframework.webflow.engine.Flow.handleEvent(Flow.java:555)
	at org.springframework.webflow.engine.impl.FlowExecutionImpl.handleEvent(FlowExecutionImpl.java:388)
	at org.springframework.webflow.engine.impl.RequestControlContextImpl.handleEvent(RequestControlContextImpl.java:210)
	at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:232)
	at org.springframework.webflow.engine.ViewState.resume(ViewState.java:196)
	at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
	at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
	at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
	at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
	at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1329)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.[url]www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150[/url])
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:445)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:556)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1038)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:374)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:972)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:363)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:483)
	at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:931)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:992)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
	at java.lang.Thread.run(Thread.java:722)
Caused by: 
org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly
	at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521) ..........
```

DANKE


----------



## Moinsn (25. Okt 2013)

Ich glaube das Problem gefunden zu haben.
Die Caskadierung war falsch konfiguriert.

cascade = CascadeType.PERSIST bedeutet dass ein child gespeichert und beim löschen des parrent nicht gelöscht wird?


----------



## KSG9|sebastian (25. Okt 2013)

Persist bedeutet das das referenzierte Objekt mitgespeichert wird.

Willst du löschen musst du zusätzlich Cascade.DELETE angeben.


----------



## Moinsn (25. Okt 2013)

ne. genau so solls sein ^^

Vielen DANK für die Hilfe.
Manchmal steckt der Teufel im Detail :idea:


----------

