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.
I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
Sarah
http://www.lyricsdigs.com
Posted by: Sarah | March 16, 2009 at 02:58 AM
I love the blog, but this issue about Converting to JBoss-5.0.0.GA is great. I read the first part to and its very interesting. It is very useful for a job that I have to present next month. Thanks again. Great work
Posted by: computer screen | April 29, 2010 at 09:35 AM
Nice article , you have indeed covered topic in details with sample code, its indeed a topic which require a deeper understanding than many other java topics.
Thanks
Javin
How Classpath works in Java
Posted by: Javin @ garbage collection in Java | April 23, 2011 at 02:57 AM