Я получаю эту ошибку при отправке формы:
org.hibernate.PersistentObjectException: отдельная сущность передана
persist: com.project.pmet.model.Account; вложенное исключение
javax.persistence.PersistenceException:
org.hibernate.PersistentObjectException: отдельная сущность передана
постоянный: com.project.stock.business.offer.Tarif
Предложение:
/**
* Offer.
*/
@Entity
@Table( name = "stock_offer" )
public class Offer extends StockEntityBean<Offer> implements Serializable
{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -6390433796484715419L;
/** Sequence name. */
private static final String JPA_SEQUENCE_NAME = "stock_offer_sequence";
/** Unique value. */
private static final String JPA_COLUMN_NAME = "stock_offer_id";
/** The _id. */
private Integer _id;
/** The _str name. */
private String _strName;
/** The _str description. */
private String _strDescription;
/** The _str statut. */
private String _strStatut;
/** The PRODUCT. */
private Product _product;
/** The _nMinTickets. */
private Integer _nMinTickets;
/** The _nMaxTickets. */
private Integer _nMaxTickets;
/** The _attribute list. */
private Set<OfferAttribute> _attributeList;
/** The _attribute date list. */
private Set<OfferAttributeDate> _attributeDateList;
/** The _attribute num list. */
private Set<OfferAttributeNum> _attributeNumList;
/** The tarifs */
private Set<Tarif> _tarifs;
/*
* @Transient private Provider _partner;
*/
/**
*
* Creates a new Offer.java object.
*/
public Offer( )
{
super( );
_product = new Product( );
_attributeDateList = new HashSet<OfferAttributeDate>( );
_attributeList = new HashSet<OfferAttribute>( );
_attributeNumList = new HashSet<OfferAttributeNum>( );
_tarifs = new HashSet<Tarif>( );
}
/**
*
* Creates a new Offer.java object.
*
* @param category
* category
*/
public Offer( Category category )
{
}
/**
* Return offer id.
*
* @return offer id
*/
@Override
@TableGenerator( table = StockJPAUtils.SEQUENCE_TABLE_NAME, name = JPA_SEQUENCE_NAME, pkColumnValue = JPA_COLUMN_NAME, allocationSize = 1 )
@Id
@GeneratedValue( strategy = GenerationType.TABLE, generator = JPA_SEQUENCE_NAME )
@Column( name = "id_offer" )
public Integer getId( )
{
return _id;
}
/**
* Set the offer id.
*
* @param idOffer
* the offer id
*/
@Override
public void setId( Integer idOffer )
{
_id = idOffer;
}
/**
* Return the offer name.
*
* @return the name
*/
@Column( name = "name" )
public String getName( )
{
return _strName;
}
/**
* Set the category name.
*
* @param name
* the offer name
*/
public void setName( String name )
{
_strName = name;
}
/**
* Return the offer description.
*
* @return the description
*/
@Column( name = "description" )
public String getDescription( )
{
return _strDescription;
}
/**
* Set the category description.
*
* @param description
* the offer description
*/
public void setDescription( String description )
{
_strDescription = description;
}
/**
* Return the PRODUCT.
*
* @return the PRODUCT
*/
@ManyToOne( optional = true, fetch = FetchType.EAGER )
@JoinColumn( name = "product_id" )
public Product getProduct( )
{
return _product;
}
/**
* Set the PRODUCT.
*
* @param product
* the PRODUCT
*/
public void setProduct( Product product )
{
_product = product;
}
/**
* Return the minimal number of tickets.
*
* @return _nMinTickets
*/
@Column( name = "min_tickets" )
public Integer getMinTickets( )
{
return _nMinTickets;
}
/**
* Set the minimal number of tickets.
*
* @param minTickets
* the minimal number of tickets
*/
public void setMinTickets( Integer minTickets )
{
_nMinTickets = minTickets;
}
/**
* Return the minimal number of tickets.
*
* @return _nMinTickets
*/
@Column( name = "max_tickets" )
public Integer getMaxTickets( )
{
return _nMaxTickets;
}
/**
* Set the maximum number of tickets.
*
* @param nMaxTickets
* the maximum number of tickets
*/
public void setMaxTickets( Integer nMaxTickets )
{
this._nMaxTickets = nMaxTickets;
}
/**
* Returns dynamic attributes list.
*
* @return dynamic attributes list
*/
@Override
@OneToMany( cascade = { CascadeType.ALL }, mappedBy = "owner", orphanRemoval = true, fetch = FetchType.EAGER )
public Set<OfferAttribute> getAttributeList( )
{
return _attributeList;
}
/**
* Sets the attribute list.
*
* @param stringAttribute
* the new attribute list
*/
public void setAttributeList( Set<OfferAttribute> stringAttribute )
{
_attributeList = stringAttribute;
}
/**
* Returns dynamic attributes list.
*
* @return dynamic attributes list
*/
@Override
@OneToMany( cascade = { CascadeType.ALL }, mappedBy = "owner", orphanRemoval = true, fetch = FetchType.EAGER )
public Set<OfferAttributeDate> getAttributeDateList( )
{
return _attributeDateList;
}
/**
* Sets the attribute date list.
*
* @param dateAttribute
* the new attribute date list
*/
public void setAttributeDateList( Set<OfferAttributeDate> dateAttribute )
{
_attributeDateList = dateAttribute;
}
/**
* Returns dynamic attributes list.
*
* @return dynamic attributes list
*/
@Override
@OneToMany( cascade = { CascadeType.ALL }, mappedBy = "owner", orphanRemoval = true, fetch = FetchType.EAGER )
public Set<OfferAttributeNum> getAttributeNumList( )
{
return _attributeNumList;
}
/**
* Sets the attribute num list.
*
* @param numAttribute
* the new attribute num list
*/
public void setAttributeNumList( Set<OfferAttributeNum> numAttribute )
{
_attributeNumList = numAttribute;
}
/**
* Sets the statut.
*
* @param statut
* the statut to set
*/
public void setStatut( String statut )
{
_strStatut = statut;
}
/**
* Gets the statut.
*
* @return the statut
*/
public String getStatut( )
{
return _strStatut;
}
@OneToMany( cascade = { CascadeType.ALL }, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "offer" )
public Set<Tarif> getTarifs( )
{
return _tarifs;
}
public void setTarifs( Set<Tarif> tarifs )
{
this._tarifs = tarifs;
}
}
Tarif:
@Entity
@Table( name = "stock_tarif" )
public class Tarif implements Serializable
{
/** Sequence name. */
private static final String JPA_SEQUENCE_NAME = "stock_tarif_sequence";
/** Unique value. */
private static final String JPA_COLUMN_NAME = "stock_tarif_id";
/** The _id. */
private Integer _id;
/** The _n quantity. */
private Integer _nQuantity;
/** The _n quantity. */
private Integer _nQuantityCanopee;
/** The _type. */
private OfferGenre _type;
private BigDecimal _price;
private Integer _initialQuantity;
private Offer _offer;
/**
*
* Creates a new Tarif.java object.
*/
public Tarif( )
{
super( );
_type = new OfferGenre( );
_offer = new Offer( );
}
// @TableGenerator( table = StockJPAUtils.SEQUENCE_TABLE_NAME, name = JPA_SEQUENCE_NAME, pkColumnValue = JPA_COLUMN_NAME, allocationSize = 1 )
@Id
// @GeneratedValue( strategy = GenerationType.TABLE, generator = JPA_SEQUENCE_NAME )
@GeneratedValue(strategy = GenerationType.AUTO)
@Column( name = "id_tarif", updatable = false, nullable = false )
public Integer getId( )
{
return _id;
}
public void setId( Integer idTarif )
{
_id = idTarif;
}
@Column( name = "quantity" )
public Integer getQuantity( )
{
return _nQuantity;
}
public void setQuantity( Integer nQuantity )
{
_nQuantity = nQuantity;
}
@Column( name = "quantityCanopee" )
public Integer getQuantityCanopee( )
{
return _nQuantityCanopee;
}
public void setQuantityCanopee( Integer quantityCanopee )
{
_nQuantityCanopee = quantityCanopee;
}
@Column( name = "price" )
public BigDecimal getPrice( )
{
return _price;
}
public void setPrice( BigDecimal price )
{
this._price = price;
}
@Column( name = "initialQuantity" )
public Integer getInitialQuantity( )
{
return _initialQuantity;
}
public void setInitialQuantity( Integer initialQuantity )
{
this._initialQuantity = initialQuantity;
}
@ManyToOne( fetch = FetchType.LAZY )
@JoinColumn( name = "offer_id" )
public Offer getOffer( )
{
return _offer;
}
public void setOffer( Offer offer )
{
this._offer = offer;
}
@ManyToOne( fetch = FetchType.EAGER )
@JoinColumn( name = "offer_genre_id" )
public OfferGenre getType( )
{
return _type;
}
public void setType( OfferGenre type )
{
_type = type;
}
}
Ошибка журнала:
Hibernate:
update
stock_sequences
set
next_val=?
where
next_val=?
and sequence_name=?
26/04/18 12:14:29 ERROR [http-nio-9090-exec-7] .....error - org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.stock.business.offer.Tarif
javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.stock.business.offer.Tarif
Что я делаю не так?