Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » soft delete is deleting relations
soft delete is deleting relations [message #731366] Fri, 30 September 2011 14:28 Go to next message
Luiz E. is currently offline Luiz E.
Messages: 97
Registered: September 2010
Member
hi all
i have entities like this
@Entity
@Table(schema=Schemas.ECF)
@Index(name="id_impressora_fiscal", columnNames={"marca","modelo","numeroFabricacao"})
@Customizer(value=ImpressoraFiscalCustomizer.class)
public class ImpressoraFiscal implements Serializable{
	private static final long serialVersionUID = 6246259319048104042L;
	
	@OneToMany(cascade={CascadeType.PERSIST}, orphanRemoval=false)
	@JoinTable(schema=Schemas.ECF)
	private List<Aliquota> aliquotas = new ArrayList<Aliquota>();




and

@Entity
@Table(schema=Schemas.ECF)
public class Aliquota implements Serializable {
	private static final long serialVersionUID = -1473589350884030504L;
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;
	
	@Column(nullable=false)
	private Double valor;


my 'ImpressoraFiscal' class is using soft delete, where i just set a boolean value to false, turning it to disabled.
but as you can see on sql logs, eclipselink is deleting all the data from the relational table
[EL Fine]: 2011-09-30 18:28:04.5--Connection(7033304)--Thread(Thread[main,6,main])--DELETE FROM ecf.IMPRESSORAFISCAL_ALIQUOTA WHERE (ImpressoraFiscal_ID = ?)
[EL Fine]: 2011-09-30 18:28:04.515--Connection(7033304)--Thread(Thread[main,6,main])--	bind => [1]
[EL Fine]: 2011-09-30 18:28:04.515--Connection(7033304)--Thread(Thread[main,6,main])--update ecf.ImpressoraFiscal set ativa = false where id = ?
[EL Fine]: 2011-09-30 18:28:04.515--Connection(7033304)--Thread(Thread[main,6,main])--	bind => [1]


what i am missing?
thanks a lot!

[Updated on: Fri, 30 September 2011 14:29]

Report message to a moderator

Re: soft delete is deleting relations [message #731890 is a reply to message #731366] Mon, 03 October 2011 08:14 Go to previous messageGo to next message
Luiz E. is currently offline Luiz E.
Messages: 97
Registered: September 2010
Member
anyone?
Re: soft delete is deleting relations [message #731901 is a reply to message #731366] Mon, 03 October 2011 08:14 Go to previous messageGo to next message
Luiz E. is currently offline Luiz E.
Messages: 97
Registered: September 2010
Member
anyone?
Re: soft delete is deleting relations [message #731983 is a reply to message #731890] Mon, 03 October 2011 11:36 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

How did you configure the class to use soft deletes?

I assume you overwrote the deleteSQL to instead be an update for the class. You will also need to do something similar for the aliquotas mapping (ManyToManyMapping also has a deletSQL and deleteAllSQL, and selectSQL).


James : Wiki : Book : Blog : Twitter
Re: soft delete is deleting relations [message #732007 is a reply to message #731983] Mon, 03 October 2011 12:40 Go to previous messageGo to next message
Luiz E. is currently offline Luiz E.
Messages: 97
Registered: September 2010
Member
I used a customizer like this

descriptor.getQueryManager().setDeleteSQLString("update ecf.ImpressoraFiscal set ativa = false where id = #id");


so, where am i going to overwrite this sqlString for my mapping? in aliquota class? you said 'aliquotas mapping'. should i overwrite it on the mapping?

thanks a lot
Re: soft delete is deleting relations [message #734052 is a reply to message #732007] Thu, 06 October 2011 10:21 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Yes in your mapping.

((ManyToManyMaping)descriptor.getMappingForAttributeName("aliquotas")).setDeleteSQLString(...)


James : Wiki : Book : Blog : Twitter
Re: soft delete is deleting relations [message #734057 is a reply to message #732007] Thu, 06 October 2011 10:21 Go to previous message
James is currently offline James
Messages: 272
Registered: July 2009
Senior Member
Yes in your mapping.

((ManyToManyMaping)descriptor.getMappingForAttributeName("aliquotas")).setDeleteSQLString(...)
--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Previous Topic:Composite Persistence and OSGi ?
Next Topic:@EmbeddedId in conjunction with InheritanceType.JOINED does not generate PK-Field
Goto Forum:
  


Current Time: Wed Aug 27 15:14:07 EDT 2014

Powered by FUDForum. Page generated in 0.02515 seconds