[JBoss Seam] - Using OneToMany with SEAM and JSF
by rgbg5
Hello,
i am totally new to SEAM and JSF, so i hope you dont mind if this is a stupid question or posted to the wrong forum. I just couldnt find a example for this.
I have a Entity class called Contacts which looks like this
|
| package gfm.entity;
|
| import java.io.Serializable;
| import java.util.ArrayList;
| import java.util.Date;
| import java.util.List;
| import javax.persistence.Entity;
| import javax.persistence.GeneratedValue;
| import javax.persistence.Id;
| import javax.persistence.JoinColumn;
| import javax.persistence.Lob;
| import javax.persistence.Temporal;
| import javax.persistence.TemporalType;
| import org.hibernate.annotations.CascadeType;
| import org.jboss.seam.annotations.Name;
| @Entity
| @Name("contact")
| public class Contact implements Serializable {
| private static final long serialVersionUID = 1L;
|
| @Id
| @org.hibernate.annotations.GenericGenerator(name="uuid_gen", strategy="uuid")
| @GeneratedValue(generator="uuid_gen")
| private String puid;
|
| private String title;
| private String firstName;
| private String middleName;
| private String lastName;
|
| private String company;
| private String department;
|
| @Temporal(TemporalType.DATE)
| private Date birthday;
|
| @Lob
| private String notes;
|
| @org.hibernate.annotations.CollectionOfElements
| @org.hibernate.annotations.IndexColumn(name="idx")
| @org.hibernate.annotations.Cascade(CascadeType.DELETE_ORPHAN)
| @JoinColumn(name="contact_puid")
| private List<StreetAddress> streetAddresses = new ArrayList<StreetAddress>();
|
| @org.hibernate.annotations.CollectionOfElements
| @org.hibernate.annotations.IndexColumn(name="idx")
| @org.hibernate.annotations.Cascade(CascadeType.DELETE_ORPHAN)
| @JoinColumn(name="contact_puid")
| private List<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
|
| @org.hibernate.annotations.CollectionOfElements
| @org.hibernate.annotations.IndexColumn(name="idx")
| @org.hibernate.annotations.Cascade(CascadeType.DELETE_ORPHAN)
| @JoinColumn(name="contact_puid")
| private List<CommNumber> commNumbers = new ArrayList<CommNumber>();
|
| // Getter and setter .....
|
| }
|
Each contact could have an unlimited number of addresses, emailaddresses and phone and faxnumbers.
The question is, how do i reference a single streetaddress from within a JSF Page ? and how do i add new streetadresses to contact ? I hope i explained that right.
An example or code snippet would be great.
Thank you very much,
Stefan
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4124311#4124311
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4124311
18 years, 2 months
[EJB 3.0] - Generate ID when creating entities
by hamtho2
Hi,
is there a chance to let the EntityManager create the ID at creation-time of an entity?
I´ve got the problem, that I want to share one id between multiple entities while having a unidirectional one-to-one relation.
This way I only have a generated value at the parent-object and for the dependent entities I have to set the id manually (to the same id, as the parent). Unfortunately the id is only generated when persisting the entity (before that the value is null), so it´s hard to propagate an object-reference to the dependant entities (even with @PrePersist as I would have to parse the parent-object).
So what I could do is to manually get the next value from my sequence and set this as an id for every entity. But if the id would be generated when a new entity is created, there won´t be a problem at all. Is there a way to achive this?
Any input would be greatly appriciated.
Thomas
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4124303#4124303
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4124303
18 years, 2 months
[JBoss Portal] - Re: Can't load CMS portlet after change datasource
by krashsun
Hi,
I stumble upon this thread http://www.jboss.org/?module=bb&op=viewtopic&p=4021091 and manage to eliminate the cms error using a new db.
But now I got the following error. Any tips to solve this?
| 16:50:26,376 WARN [ServiceObjectFactory] Unable to narrow port selection for
| UnifiedPortComponentRef
| serviceEndpointInterface=org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortTy
| pe
| portQName=null
| enableMTOM=false
| portComponentLink=null
| callProperties=[]
| stubProperties=[]
| configName=null
| configFile=null
| 16:50:26,501 WARN [HandlerWrapper] Handler is in state DOES_NOT_EXIST, skipping
| Handler.handleFault for: org.jboss.portal.wsrp.handler.RequestHeaderClientHandl
| er@eff0c
| 16:50:26,501 WARN [HandlerWrapper] Handler is in state DOES_NOT_EXIST, skipping
| Handler.handleFault for: org.jboss.portal.wsrp.handler.WSRPExtensionHandler@412
| 161
| 16:50:26,517 ERROR [Scheduler$Listener] Invoke of the Schedulable MBean failed
| javax.management.MBeanException
| at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptio
| ns(ReflectedDispatcher.java:180)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
| er.java:163)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
| or.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
| BeanOperationInterceptor.java:142)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
| java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.varia.scheduler.Scheduler$MBeanListener.handleNotification(
| Scheduler.java:1346)
| at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
| sorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.jboss.mx.notification.NotificationListenerProxy.invoke(Notificati
| onListenerProxy.java:153)
| at $Proxy11.handleNotification(Unknown Source)
| at javax.management.NotificationBroadcasterSupport.handleNotification(No
| tificationBroadcasterSupport.java:257)
| at javax.management.NotificationBroadcasterSupport$SendNotifJob.run(Noti
| ficationBroadcasterSupport.java:322)
| at javax.management.NotificationBroadcasterSupport$1.execute(Notificatio
| nBroadcasterSupport.java:307)
| at javax.management.NotificationBroadcasterSupport.sendNotification(Noti
| ficationBroadcasterSupport.java:229)
| at javax.management.timer.Timer.sendNotification(Timer.java:1234)
| at javax.management.timer.Timer.notifyAlarmClock(Timer.java:1203)
| at javax.management.timer.TimerAlarmClock.run(Timer.java:1286)
| at java.util.TimerThread.mainLoop(Timer.java:512)
| at java.util.TimerThread.run(Timer.java:462)
| Caused by: org.jboss.portal.portlet.InvokerUnavailableException: Problem getting
| service description for producer self, please see the logs for more information
| .
| at org.jboss.portal.wsrp.consumer.WSRPConsumerImpl.getPortlets(WSRPConsu
| merImpl.java:157)
| at org.jboss.portal.portlet.federation.impl.FederatedPortletInvokerServi
| ce.getPortlets(FederatedPortletInvokerService.java:90)
| at org.jboss.portal.core.management.PortletDiscoveryService.processPortl
| etDiscovery(PortletDiscoveryService.java:88)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
| java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
| sorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:597)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
| er.java:155)
| ... 22 more
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4124301#4124301
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4124301
18 years, 2 months