[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
em.persist(o); em.flush(); o.getId(); View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044895#4044895 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044895 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
This is how i have used oracle sequence. sequenceName="CUSTOMER_SEQ": Is the name is the name of your database sequence. name="CUSTOMER_SEQUENCE": U will use in Entity as i have used it with id field. / @Entity @Name("Customer") @Scope(EVENT) @Table(name="Customer") @SequenceGenerator(name="CUSTOMER_SEQUENCE", sequenceName="CUSTOMER_SEQ") public class ERegCustomer implements Serializable { private Integer id; @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="CUSTOMER_SEQUENCE") public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044923#4044923 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044923 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
Thanks for your reply christian well and injecting EntityManager like this in my action class @PersistenceContext(unitName="myDatabase") protected EntityManager em; i think it will not allow me to use em.flush function as i think so i have tried it before and it throughs exception.(As per my information it is managed by the seam and it does not allow it.) View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044924#4044924 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044924 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
Hello, can someone give me some advice on how to setup a generated ID with Oracle, hibernate and SEAM... I have been trying to do a variety of ways - like "before insert" triggers and coupled with @GeneratedValue(strategy=GenerationType.IDENTITY) or @GeneratedValue(strategy=GenerationType.AUTO), but that didn't work. I have tried going straight to the sequence with: @Id @Column(name = "LISTINGTYPE_ID", unique = true, nullable = false, precision = 22, scale = 0) @SequenceGenerator(name="identifier", sequenceName="LISTINGTYPE_SEQ", allocationSize=1) @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="identifier") @NotNull That didn't work, it kept complaining the sequence didn't exist, although it did exist. I have read a dozen or more postings and can't get the right recipe working for Oracle. I really appreciate your help. Thanks!!! View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044919#4044919 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044919 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
You can call em.flush() whenever you want, nobody can prevent that. However, if "whenever" is a good time to synchronize in-memory persistence context state with the database is another question. An exception would probably indicate that this is not a good time. So no, you don't have any way or guarantee to get an identifier from an entity until it is finally persisted during flushing. One other hand, if you use a sequence generator, Hibernate will assign an identifier to the instance at the time you call persist(o). But this is an implementation detail and not standardized anywhere. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044959#4044959 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044959 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
Thanks for the info on the sequence - but it still gives me the same problem: 12:15:22,362 ERROR [URLDeploymentScanner] Incomplete Deployment listing: --- MBeans waiting for other MBeans --- ObjectName: persistence.units:ear=naturalmed2.ear,unitName=naturalmed2 State: FAILED Reason: javax.persistence.PersistenceException: org.hibernate.HibernateExcepti on: Missing sequence or table: NM.LISTINGTYPE_SEQ I Depend On: jboss.jca:service=DataSourceBinding,name=naturalmed2Datasource --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM --- ObjectName: persistence.units:ear=naturalmed2.ear,unitName=naturalmed2 State: FAILED Reason: javax.persistence.PersistenceException: org.hibernate.HibernateExcepti on: Missing sequence or table: NM.LISTINGTYPE_SEQ I Depend On: jboss.jca:service=DataSourceBinding,name=naturalmed2Datasource And I have double checked that the sequence is there in that NM schema... This is consistent with what I have notice with other attempts too. Any thoughts? Thanks again! View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045108#4045108 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045108 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
This is really turning into a Hibernate question. Your entity should have an identifier after you call persist(o), no matter where as long as you have a sequence-style generator. I recommend enabling the Hibernate DEBUG log and posting on the Hibernate forum. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045197#4045197 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045197 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
Well, if Hibernate says the sequence isn't there it probably isn't there or can't be seen by the user Hibernate connects with. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045198#4045198 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045198 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
anonymous wrote : Your entity should have an identifier after you call persist(o), no matter where as long as you have a sequence-style generator. So Hibernate actually calls the mutator after persisting (or implicitly refreshes)? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045199#4045199 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045199 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
Your sequence looks correct. I don't have the code here but I think I'm doing this: em.persist(entity); | em.flush(); | em.refresh(entity); to get the sequence. I don't think EntityManager uses the primary key to find the persistent state. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045196#4045196 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045196 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
Hibernate sets the identifier property, through field or setter access. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045216#4045216 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045216 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
(You don't need an INSERT to get the next identifier value from a sequence.) View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045217#4045217 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045217 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
Sorry. I know this is slightly off topic of your question - please forgive me. but I am still having the same problem whereby, it says the sequence does not exists... I am using jboss-4.0.5.GA w/EJB installed on Window XP runing 10g XE on same machine. This one issue is enough to kill my project in SEAM, and I really wanted to give this a try. I need to be able to use SEQUENCE directly or before insert triggers (which invoke the sequence before actual insert). I don't care which way I go, but if I use the method proposed here, I get: --- MBeans waiting for other MBeans --- | ObjectName: persistence.units:ear=naturalmed2.ear,unitName=naturalmed2 | State: FAILED | Reason: javax.persistence.PersistenceException: org.hibernate.HibernateException: Missing sequence or table: NM.LISTINGTYPE_SEQ | I Depend On: | jboss.jca:service=DataSourceBinding,name=naturalmed2Datasource | | --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM --- | ObjectName: persistence.units:ear=naturalmed2.ear,unitName=naturalmed2 | State: FAILED | Reason: javax.persistence.PersistenceException: org.hibernate.HibernateException: Missing sequence or table: NM.LISTINGTYPE_SEQ | I Depend On: | jboss.jca:service=DataSourceBinding,name=naturalmed2Datasource and again, the sequence is there (double checked). Also, I should mention that I am working with the code generated by SEAM generate-entities. Thank you for any help you can give. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045659#4045659 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045659 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
Is your ID field in your Entity annotated with @GeneratedValue ? This caused me all sorts of grief with my Seam Gen'd project until I figured out it's significance. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045689#4045689 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045689 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
I fixed the problem - it was that the persistance.xml had the following defined. I needed this to run the "seam generate-entities" or else all the tables in the system space were being generated to. Thank you for your code suggestion. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045822#4045822 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045822 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
I fixed the problem - it was that the persistance.xml had the following defined. I needed this to run the "seam generate-entities" or else all the tables in the system space were being generated to. Thank you for your code suggestion. -Joel View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045821#4045821 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045821 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Getting Id of Presisted object.
my xml didn't show up in the previous post - I will enclose in "code" tags - this is what I had to get rid of : View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045823#4045823 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045823 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user