[EJB 3.0] - Question @Inheritance
by pKraemer
Well it's me again with a question for using @Inheritance
Well I got one super Entity:
| @Entity
| @Table(name="users")
| @SequenceGenerator(name = "user_sequence", sequenceName = "user_id_seq")
| @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
| public class User implements Serializable {
|
| private static final long serialVersionUID = 1487970457796785528L;
| @Id
| @Column(name="u_id",nullable=false)
| @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_sequence")
| private Long id;
| ....
| }
|
and a child class
| @Entity
| @Table(name="registered_user")
| public class RegisteredUser extends User implements Serializable{
|
| private static final long serialVersionUID = 2027308984532828735L;
| ....
| }
|
with no specific id.
Both entities are represented by an own table. The Primary Key from the parent table is also used as primary key in child table (mapped with foreign key)
When I try to persist a child object I got an Error:
anonymous wrote :
| 18:19:46,968 ERROR [JDBCExceptionReporter] ERROR: insert or update on table "registered_user" violates foreign key constraint "fk22ff4768223777df"
| Detail: Key (u_id)=(1600) is not present in table "users".
| 18:19:46,968 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
|
How can I tell the manager to persist the attributes in my parent table? Perhaps with cascade strategy? And where should I put it?
Thx a lot
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036448#4036448
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036448
19 years
[JBoss Messaging] - Re: Number of topic subscriptors
by mskonda
Here's the method that would do what you need.
| private void testSubscriptionsList(String destName, String type) throws Exception {
|
| QueueMBean queueMBean = null;
| TopicMBean topicMBean = null;
|
| try {
| //find the mbean server
| mBeanServer = (MBeanServerConnection) new InitialContext().lookup("jmx/invoker/RMIAdaptor");
|
| // create the relevant ON
| // Here type equals to Queue or Topic and
| // destName equals to name of the destination, for example testTopic
|
| serverObjectName = new ObjectName(
| "jboss.messaging.destination:service=" + type + ",name="
| + destName);
|
| // create either queueMBean or topicMBean
| if (type.equalsIgnoreCase("Queue")) {
|
| queueMBean = (QueueMBean) MBeanServerInvocationHandler
| .newProxyInstance(mBeanServer, serverObjectName,
| QueueMBean.class, false);
|
| } else if (type.equalsIgnoreCase("Topic")) {
|
| topicMBean = (TopicMBean) MBeanServerInvocationHandler
| .newProxyInstance(mBeanServer, serverObjectName,
| TopicMBean.class, false);
| }
|
| } catch (NamingException e) {
| logger.warn("NamingException:" + e.getMessage());
| logger.error(e);
| } catch (Exception e) {
| logger.info("Exception:" + e.getMessage());
| logger.error(e);
| }
|
| // once you get the relevant MBean, invoke
| // the appropriate operations.
| // For example, to list the subscription on the topic
| // do this:
| List subs = topicMBean.listAllSubscriptions();
|
| // iterate through the list..
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036447#4036447
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036447
19 years
[JBossWS] - Re: JSR-109Client, Mapping problem and trying to connect to
by d_pavel
OK this is what I discovered:
The "Could not update IN parameter to be INOUT..." error comes from processOutputDocElement method inside JAXRPCMetaDataBuilder class. The processOutputDocElement is called from
anonymous wrote :
| buildParameterMetaDataDoc(OperationMetaData opMetaData, WSDLInterfaceOperation wsdlOperation, ServiceEndpointMethodMapping seiMethodMapping,TypeMappingImpl typeMapping)
|
Now the description of this class is mentioning: "A meta data builder that is based on webservices.xml." So I supposed that this error occurs due to issues related to my webservices.xml.
Here is my webservices.xml :
| <webservices version='1.1' xmlns='http://java.sun.com/xml/ns/j2ee' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd'>
| <webservice-description>
| <webservice-description-name>Vax</webservice-description-name>
| <wsdl-file>WebRoot/WEB-INF/wsdl/Vax.wsdl</wsdl-file>
| <jaxrpc-mapping-file>WebRoot/WEB-INF/jaxrpc-mapping.xml</jaxrpc-mapping-file>
| <port-component>
| <port-component-name>VaxSoapPort</port-component-name>
| <!-- wsdl-port xmlns:portNS='https://www.acompany.com/VaxHttpTest/Vax.asmx'>portNS:VaxSoapPort</wsdl-port -->
| anonymous wrote : <wsdl-port xmlns:portNS='https://www.acompany.com/VaxHttpTest/VaxSoap'>portNS:VaxSoapPort</wsdl-port>
| <service-endpoint-interface>ca.agenthttp.vax.VaxSoap</service-endpoint-interface>
| <service-impl-bean>
| <servlet-link>VaxSoap</servlet-link>
| </service-impl-bean>
| </port-component>
| </webservice-description>
| </webservices>
|
Now from the docs we know:
anonymous wrote :
| The port-component-name element specifies a port component's name. This name is assigned by the module producer to name the service implementation bean in the module's deployment descriptor. The name must be unique among the port component names defined in the same module.
| Used in: port-component
| Example:
| <port-component-name>EmployeeService
| </port-component-name>
|
So according to this the wsdl-port tag line should be like this:
anonymous wrote :
| <wsdl-port xmlns:portNS='https://www.acompany.com/VaxHttpTest/VaxSoap'>portNS:VaxSoapPort</wsdl-port>
|
I tried also to provide the target namespace like in the commented line:
anonymous wrote :
| <!-- wsdl-port xmlns:portNS='https://www.acompany.com/VaxHttpTest/Vax.asmx'>portNS:VaxSoapPort</wsdl-port -->
|
(even if I know the correct use is like in the previous uncommented line) but with same error results:
anonymous wrote :
| Could not update IN parameter to be INOUT, as indicated in the mapping: parameters
|
Is it possible that this occurs because the wsdl location URL points to
anonymous wrote :
| https://www.acompany.com/VaxHttp/Vax?wsdl
|
but the real SEI is in fact "VaxSoap" class ???
Let me explain: "Vax" referenced in URL is just a simple javax.xml.rpc.Service and looks like this:
| /*
| * JBoss, the OpenSource EJB server
| * Distributable under LGPL license. See terms of license at gnu.org.
| */
|
| //Auto Generated by jbossws - Please do not edit!!!
|
| package ca.agenthttp.vax;
|
|
| import javax.xml.rpc.*;
|
|
| public interface Vax extends javax.xml.rpc.Service
| {
|
| public ca.agenthttp.vax.VaxSoap getVaxSoap() throws ServiceException;
|
| }
|
Now the ca.agenthttp.vax.VaxSoap is my real SEI which contains references to all the published methods which are web servable.
Please confirm to me if this webservices.xml is properly configured or if I have to reconfigure some other .xml files.
Last but not least this is my jboss-client.xml file:
| <?xml version="1.0" encoding="UTF-8"?>
|
| <jboss-client>
| <jndi-name>jbossws-client</jndi-name>
| <service-ref>
| <service-ref-name>Vax</service-ref-name>
| <wsdl-override>
| https://www.acompany.com/VaxHttpTest/Vax.asmx?wsdl
| </wsdl-override>
| </service-ref>
| </jboss-client>
|
The service defined in Wax.wsdl looks like this:
| <wsdl:service name="Vax">
| <wsdl:port name="VaxSoap" binding="tns:VaxSoap">
| <soap:address location="https://www.acompany.com/VaxHttpTest/Vax.asmx" />
| </wsdl:port>
| </wsdl:service>
|
Any suggestions ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036444#4036444
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036444
19 years
[Persistence, JBoss/CMP, Hibernate, Database] - Setting primary key in valueobject using XDoclet and unknown
by swing
Hi,
I'm having problems with my VOs in XDoclet.
I can generate my VOs allright, and using them on client side is a great releaf.
When receiving VOs back from client, I would like to update the bean by calling setXXXValue(vo) in the bean, but because the CMP layer doesn't set the pk automatically when creating the VO, an exceptions is thrown because the CMP layer can't get hold of other beans referenced by the bean to be updated.
I have searched the web like a mad man, but it seems that nobody have touched upon this issue.
I'm aware that when using unknown-pk, I give complete control of the PK to the CMP layer, but never the less, it would be smart to have the correct PK in the VO.
Is there a work around, or should I use a different approach than VOs?
Bean in questing:
/**
| * XDoclet-based CMP 2.x entity bean. This class must be declared
| * public abstract because the concrete class will
| * be implemented by the CMP providers tooling.
| *
| * To generate EJB related classes using XDoclet:
| *
| * - Add Standard EJB module to XDoclet project properties
| * - Customize XDoclet configuration
| * - Run XDoclet
| *
| * Below are the xdoclet-related tags needed for this EJB.
| *
| * @ejb.bean name="Customer"
| * display-name="Name for Customer"
| * description="Description for Customer"
| * jndi-name="ejb/Customer"
| * primary-key-class="java.lang.Object"
| * type="CMP"
| * cmp-version="2.x"
| * view-type="local"
| *
| * @ejb.pk class="java.lang.Object"
| * @ejb.util generate="physical"
| * @ejb.persistence table-name="Customer"
| * @ejb.value-object
| *
| * @ejb.ejb-external-ref
| * view-type="local"
| * link="User"
| * ref-name="ejb/UserLocal"
| * type="Entity"
| * home="com.tmn.ejb.user.entity.generated.UserLocalHome"
| * business="com.tmn.ejb.user.entity.generated.UserLocal"
| * @ejb.ejb-external-ref
| * view-type="local"
| * link="IPPhoneSubscription"
| * ref-name="ejb/IPPhoneSubscriptionLocal"
| * type="Entity"
| * home="com.tmn.ejb.product.entity.generated.IPPhoneSubscriptionLocalHome"
| * business="com.tmn.ejb.product.entity.generated.IPPhoneSubscriptionLocal"
| *
| * @ejb.finder
| * signature="com.tmn.contentdanmark.ejb.user.entity.generated.CustomerLocal findLocalByUserName(java.lang.String userName)"
| * query="SELECT OBJECT(a) FROM Customer a WHERE ( a.user.userName=?1 )"
| *
| * @ejb.finder
| * signature="java.util.Collection findAll()"
| * query="SELECT OBJECT(a) FROM Customer a"
| */
| public abstract class CustomerEJB implements EntityBean {
|
| /** The entity context */
| private EntityContext context;
|
| private java.util.Date creationDate;
|
| /**
| * There are zero or more ejbCreate<METHOD>(...) methods, whose signatures match
| * the signatures of the create<METHOD>(...) methods of the entity bean?s home interface.
| * The container invokes an ejbCreate<METHOD>(...) method on an entity bean instance
| * when a client invokes a matching create<METHOD>(...) method on the entity bean?s
| * home interface.<br>
| *
| * The entity bean provider?s responsibility is to initialize the instance in the ejbCreate<
| * METHOD>(...) methods from the input arguments, using the get and set accessor
| * methods, such that when the ejbCreate<METHOD>(...) method returns, the persistent
| * representation of the instance can be created. <br>
| *
| * The entity bean provider must not attempt to modify the values of cmr-fields in an ejbCreate<
| * METHOD(...) method; this should be done in the ejbPostCreate<METHOD(...) method instead.<br>
| *
| * The entity object created by the ejbCreate<METHOD> method must have a unique primary
| * key. This means that the primary key must be different from the primary keys of all the existing
| * entity objects within the same home. However, it is legal to reuse the primary key of a previously
| * removed entity object. The implementation of the bean provider?s ejbCreate<
| * METHOD>(...) methods should be coded to return a null.<br>
| *
| * An ejbCreate<METHOD>(...) method executes in the transaction context determined by
| * the transaction attribute of the matching create<METHOD>(...) method.
| * The database insert operations are performed by the container within the same
| * transaction context after the Bean Provider?s ejbCreate<METHOD>(...) method completes.
| *
| * @throws CreateException Thrown if method fails due to system-level error.
| * @param creationDate
| *
| * @ejb.create-method
| */
| public java.lang.Object ejbCreate(Date creationDate) throws CreateException {
| this.setCreationDate(creationDate);
| return null;
| }
|
| /**
| * For each ejbCreate<METHOD>(...) method, there is a matching ejbPostCreate<
| * METHOD>(...) method that has the same input parameters but whose return type is
| * void. The container invokes the matching ejbPostCreate<METHOD>(...) method on
| * an instance after it invokes the ejbCreate<METHOD>(...) method with the same arguments.
| * The instance can discover the primary key by calling getPrimaryKey() on its
| * entity context object. <br>
| *
| * The entity object identity is available during the ejbPostCreate<METHOD>(...)
| * method. The instance may, for example, obtain the component interface of the associated entity
| * object and pass it to another enterprise bean as a method argument.<br>
| *
| * The entity Bean Provider may use the ejbPostCreate<METHOD>(...) to set the values
| * of cmr-fields to complete the initialization of the entity bean instance.
| * An ejbPostCreate<METHOD>(...) method executes in the same transaction context as
| * the previous ejbCreate<METHOD>(...) method.
| *
| * @throws CreateException Thrown if method fails due to system-level error.
| */
| public void ejbPostCreate(Date creationDate) throws CreateException {
| }
|
| public void ejbActivate() throws EJBException, RemoteException {
| // TODO Auto-generated method stub
|
| }
|
| public void ejbLoad() throws EJBException, RemoteException {
| // TODO Auto-generated method stub
|
| }
|
| public void ejbPassivate() throws EJBException, RemoteException {
| // TODO Auto-generated method stub
|
| }
|
| public void ejbRemove()
| throws RemoveException,
| EJBException,
| RemoteException {
| // TODO Auto-generated method stub
|
| }
|
| public void ejbStore() throws EJBException, RemoteException {
| // TODO Auto-generated method stub
|
| }
|
| /**
| * Set the associated entity context. The container calls this method
| * after the instance creation. The entity bean must not attempt to
| * access its persistent state and relationships using the accessor
| * methods during this method. <br>
| *
| * The enterprise bean instance should store the reference to the context
| * object in an instance variable. <br>
| *
| * This method is called with no transaction context.
| *
| * @throws EJBException Thrown if method fails due to system-level error.
| */
| public void setEntityContext(EntityContext newContext) throws EJBException {
| context = newContext;
| }
|
| /**
| * Unset the associated entity context. A container invokes this method
| * before terminating the life of the instance. The entity bean must not
| * attempt to access its persistent state and relationships using the
| * accessor methods during this method. <br>
| *
| * This method is called with no transaction context.
| *
| * @throws EJBException Thrown if method fails due to system-level error.
| */
| public void unsetEntityContext() throws EJBException {
| context = null;
| }
|
| /**
| * @return the creationDate
| *
| * @ejb.persistence
| * @ejb.interface-method view-type="both"
| */
| public abstract java.util.Date getCreationDate();
| /**
| * @param creationDate the creationDate to set
| *
| * @ejb.interface-method view-type="both"
| */
| public abstract void setCreationDate(java.util.Date creationDate);
|
| /**
| * @ejb.value-object
| * compose="com.tmn.ejb.user.entity.generated.UserValue"
| * compose-name="UserValue"
| *
| * @ejb.relation
| * name="Customer-User"
| * role-name="Customer-CanBe-User"
| * target-ejb="User"
| * target-role-name="User-CanBeA-Customer"
| *
| * @ejb.interface-method view-type="both"
| */
| public abstract com.tmn.ejb.user.entity.generated.UserLocal getUser();
| /**
| * @ejb.interface-method view-type="local"
| */
| public abstract void setUser(com.tmn.ejb.user.entity.generated.UserLocal user);
|
| /**
| * @ejb.value-object
| * compose="com.tmn.ejb.product.entity.generated.IPPhoneSubscriptionValue"
| * compose-name="IPPhoneSubscriptionValue"
| *
| * @ejb.relation
| * name="Customer-IPPhoneSubscription"
| * role-name="Customer-CanHave-IPPhoneSubscription"
| * target-ejb="IPPhoneSubscription"
| * target-role-name="IPPhoneSubscription-BelongsTo-Customer"
| *
| * @ejb.interface-method view-type="both"
| */
| public abstract com.tmn.ejb.product.entity.generated.IPPhoneSubscriptionLocal getIPPhoneSubscription();
| /**
| * @ejb.interface-method view-type="local"
| */
| public abstract void setIPPhoneSubscription(com.tmn.ejb.product.entity.generated.IPPhoneSubscriptionLocal iPPhoneSubscription);
|
| /**
| * Return the value object version of this entity.
| *
| * @ejb.interface-method view-type="local"
| */
| public abstract com.tmn.contentdanmark.ejb.user.entity.generated.CustomerValue getCustomerValue();
|
| /**
| * Set the value object version of this entity.
| *
| * @ejb.interface-method view-type="local"
| */
| public abstract void setCustomerValue(com.tmn.contentdanmark.ejb.user.entity.generated.CustomerValue value);
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036439#4036439
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036439
19 years