In this post I continue describing the conversion from glassfish to
Native SQL One problem I hit was in lab6 of chapter 5. This deals with native SQL queries in JPQL. In JBoss if one field definition is specified in a @FieldResult, then all fields for that class need to be specified even if they map onto the same column name. For example we may have the query: @SqlResultSetMapping( name="CustomerAccountResults", entities={@EntityResult(entityClass=ejb30.entity.Account.class, fields={@FieldResult(name="id", column="ACC_ID"), @FieldResult(name="accountType", column="ACCOUNTTYPE"), @FieldResult(name="balance", column="BALANCE"), @FieldResult(name="customer", column="CUSTOMER_ID") } ), @EntityResult(entityClass=ejb30.entity.Customer.class) } ),
Because we need to add the first @FieldResult entry to map id to column ACC_ID, we need to add a @FieldResult entry for every field in Account. This applies for fields such as accountType and balance which map onto columns with the same name. According to the JPA spec such FieldResult mappings are optional. If we dont have a FieldResult mapping in JBoss we get a runtime error along the lines:
[JDBCExceptionReporter] Column not found: balance6_0_
Messaging
Chapter 8 deals with JMS Messaging. To create JMS resources such as a JMSQueue named BankServiceJMSQueue a JMSTopic named BankServiceJMSTopic a JMSConnectionFactory named BankServiceConnectionFactory we first need to create the following chap08-service.xml file:
<?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=BankServiceJMSQueue"> <attribute name="JNDIName">BankServiceJMSQueue</attribute> <depends optional-attribute-name="DestinationManager"> jboss.mq:service=DestinationManager</depends> </mbean> <mbean code="org.jboss.mq.server.jmx.Topic" name="jboss.mq.destination:service=Topic,name=BankServiceJMSTopic"> <attribute name="JNDIName">BankServiceJMSTopic</attribute> <depends optional-attribute-name="DestinationManager"> jboss.mq:service=DestinationManager</depends> </mbean> <mbean code="org.jboss.jms.server.connectionfactory.ConnectionFactory" name="jboss.messaging.connectionfactory:service=BankServiceConnectionFactory" xmbean-dd="xmdesc/ConnectionFactory-xmbean.xml"> <attribute name="JNDIBindings"> <bindings> <binding>BankServiceConnectionFactory</binding> </bindings> </attribute> <depends optional-attribute-name="ServerPeer"> jboss.messaging:service=ServerPeer </depends> <depends optional-attribute-name="Connector"> jboss.messaging:service=Connector,transport=bisocket </depends> <depends>jboss.messaging:service=PostOffice </depends> </mbean> </server> The above xml file can be named anything but must end in "-service.xml". We have chosen chap08-service.xml. This xml file is then copied to the deploy directory. We have the following ant target in our build file: <target name="create-jms-resources"> <copy file="chap08-service.xml" todir="${jboss.home}/server/default/deploy"/> </target> That's it for now. My next post will deal with Web Services.