[EJB 3.0] - Re: eager vs. lazy fetching
by amitvk
Another way I found useful was using the OOP concepts to load the mappings or just the core table vlaues.
Have the main table mapped in the superclass and the mappings that you want to load sometimes in the subclass.
e.g. If the table name is Customer.
have 2 entities Customer, and CustomerWithMapping
CUstomerWithMapping extends Customer.
Define all the Customer column values in Customer base class.
Define all the lazy mappings in CustomerWithMapping class with EAGER fetch..
If you just want to get the core table data find on the Customer. If you want it with mappings call e.g. Select e from CustomerMapping where e.CustomerNumber =1.
I used the Customer class when I want to display list of customers and CustomerWithMapping when working on a specefic Customer.
Hope this helps.
P.S the only problem I found was that you cannot use em.find to get the CustomerWithMapping Object as it tries to load the superclass.
In that case use JPQL - Select e from CustomerMapping where e.CustomerNumber =1
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4126326#4126326
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4126326
18 years, 2 months
[EJB 3.0] - Re: eager vs. lazy fetching
by amitvk
Another way I found useful was using the OOP concepts to load the mappings or just the core table vlaues.
Have the main table mapped in the superclass and the mappings that you want to load sometimes in the subclass.
e.g. If the table name is Customer.
have 2 entities Customer, and CustomerWithMapping
CUstomerWithMapping extends Customer.
Define all the Customer column values in Customer base class.
Define all the lazy mappings in CustomerWithMapping class with EAGER fetch..
If you just want to get the core table data find on the Customer. If you want it with mappings call e.g. Select e from CustomerMapping where e.CustomerNumber =1.
I used the Customer class when I want to display list of customers and CustomerWithMapping when working on a specefic Customer.
Hope this helps.
P.S the only problem I found was that you cannot use em.find to get the CustomerWithMapping Object as it tries to load the superclass.
In that case use JPQL - Select e from CustomerMapping where e.CustomerNumber =1
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4126325#4126325
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4126325
18 years, 2 months
[JBoss Portal] - Re: custom portal + css images
by JohnnyTheHun
Thanks for the help, after your post, I saw the flaw in my thinking.
Putting the theme into a seperate war was a very good idea, didn't notice that in the reference guide.
Above putting the theme there, I also put my own layout too (and the whole portal for simplicity's sake), and with a bit of myportal-object.xml tweaking I don't have to use the management portlet either.
If it's any help to anyone, my dir structure:
| mytheme.war
| + my_styles.css
| + mylayout.jsp
| + WEB-INF/
| + portal-layouts.xml
| + portal-themes.xml
| + myportal-object.xml
| + web.xml
| + jsp/
| + <my jsp files>
| + images/
| + mylogo.gif
| + myicon.ico
| + <lots more images>
| <etc...>
|
portal-themes.xml:
| <themes>
| <theme>
| <name>my_theme</name>
| <link rel="stylesheet" id="main_css" href="/my_styles.css" type="text/css"/>
| <link rel="shortcut icon" href="/images/favicon.ico"/>
| </theme>
| </themes>
|
portal-layouts.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <layouts>
| <layout>
| <name>my_layout</name>
| <uri>/index.jsp</uri>
| <uri state="maximized">/index.jsp</uri>
| <regions>
| <region name="left"/>
| <region name="center"/>
| </regions>
| </layout>
| </layouts>
|
part of myportal-object.xml:
| ......
| <page>
| <page-name>MyPage</page-name>
| <properties>
| <property>
| <name>theme.renderSetId</name>
| <value>divRenderer</value>
| </property>
| <property>
| <name>theme.id</name>
| <value>my_theme</value>
| </property>
| <property>
| <name>layout.id</name>
| <value>my_layout</value>
| </property>
| <property>
| <name>order</name>
| <value>1</value>
| </property>
| </properties>
|
| <window>
| ...
| </window>
| .......
| </page>
| .....
|
And if you by any chance are such a messy coder, that you're using tags in your layout, then you can reference your images in your .jsp via:
| <%
| String contextPath = request.getContextPath();
| %>
| ......
| <img src="<%=contextPath %>/images/yourPic.jpg"/>
| ......
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4126317#4126317
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4126317
18 years, 2 months