[JBoss Seam] - Re: Dependent Fields in 2 Classes Best Practice?
by chuckadams
You could take the suggestion of using persistence events to accumulate a running tally, but I would at most use such a total to update the UI with a "non-authoritative figure". Especially for financial data, you should only have one authoritative definition of any figure, and that should be from the only source that is guaranteed to have all the data, and that's the database. Your app might not be the only thing that ever updates the expenses tables in the future.
You probably don't want to do the sums by fetching all the expense objects though, so you'd be best off with a scalar query, a raw sql query, or best yet, a stored procedure. It's going to be ridiculously fast in almost any database, and lends itself to optimizations like partitioning if you need it.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029059#4029059
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029059
19Â years, 1Â month
[Persistence, JBoss/CMP, Hibernate, Database] - SerializationException
by eelgueta
Hi All,
When I'm persisting some entities, everything seems to be going fine, util I get this error:
| javax.ejb.EJBException: org.hibernate.type.SerializationException: could not serialize
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
| :
| Caused by: org.hibernate.type.SerializationException: could not serialize
| at org.hibernate.util.SerializationHelper.serialize(SerializationHelper.java:152)
| at org.hibernate.util.SerializationHelper.serialize(SerializationHelper.java:172)
| :
| Caused by: java.io.NotSerializableException: cl.navix.benji.HotelReservationBooking
| at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
| at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
|
How can I tell what's wrong with this class?
I'm using JBoss 4.0.3 SP1. And the class is quite simple: 6 int fields, 1 varchar and 1 text (in database).
Any help. very welcomed as this is confusing! A very similar class has no problem.
Thank you.
Edo.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029054#4029054
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029054
19Â years, 1Â month
[EJB 3.0] - Deleting parent entity should clear out its foreign key in c
by TheXFed
I'm having an issue where deleting the parent entity isn't clearing out the Foreign Keys in the child entities (since I don't have cascade REMOVE from the parent to the child entities).
In my application, I will assign a category (parent) to an entry (child) and save the entry which will update the category FK. However, when I delete a category, I'd like all FKs to that category in the entries collection to be cleared out.
Currently when deleting a Category (that I just loaded, which has a couple of Entries in its collection) I only see a "delete from category where ..." SQL statement being executed. I'd expect to also see a couple "update entry set category_id=null where ..." so the FKs get cleared out.
I tried to use the JoinColumn annotation on the Entry side to see if that would help, but that didn't seem to change any behavior:
@JoinColumn(name="category_id", insertable=true, updatable=true, nullable=true)
Any help would be much appreciated.
| // ************* CATEGORY ENTITY (parent) ******************
|
| @Entity
| @Table(name="category")
| public class Category extends BaseEntity {
| ...
| @Id
| @GeneratedValue(strategy=GenerationType.TABLE, generator="hilo")
| @TableGenerator(name="hilo", table="HIBBY_KEY", initialValue=100,
| pkColumnValue="category", pkColumnName="table_name", valueColumnName="next_hi", allocationSize=1)
| private Long id;
| @OneToMany(mappedBy="category")
| public Collection<Entry> entries;
|
| ...
| }
|
|
| // ************* ENTRY ENTITY (child) ******************
| // (Subclasses of this entity don't have anything significant in them)
| @Entity
| @Table(name="entry")
| @DiscriminatorColumn(name="entry_type", discriminatorType=DiscriminatorType.STRING, length=1)
| public abstract class Entry extends BaseEntity {
| ...
| @Id
| @GeneratedValue(strategy=GenerationType.TABLE, generator="hilo")
| @TableGenerator(name="hilo", table="HIBBY_KEY", initialValue=100,
| pkColumnValue="entry", pkColumnName="table_name", valueColumnName="next_hi", allocationSize=1)
| private Long id;
| @ManyToOne(optional=true, fetch=FetchType.EAGER)
| public Category category;
|
| ...
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029051#4029051
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029051
19Â years, 1Â month