osdir.com
mailing list archive

Subject: Re: Slice Error with simple query ( Websphere 7.0 & DB2 9.1 ) - msg#00306

List: users.openjpa.apache.org

Date: Prev Next Index Thread: Prev Next Index

> Can't I use slice framework with databases which not have the same structure ?

Slice assumes that data is horizontally partitioned i.e. as if a huge table is
sliced row-wise and put into many separate databases. But this assumption is
not a hard one. You can use Slice even when the slices do not have the same
schema but it will not be as seamless as in the case of identical schemas.

What Slice can not do is if slice-1 and slice-2 both contains table named 'T'
but these two tables have different structures.

What Slice can do is
1. slice-1: has table T1,T2
slice-2: has Table T2,T3
And T2 in slice1 and slice2 have identical schema.

2. The Java entities C1, C2, C3 maps to T1,T2,T3 respectively

3. Your application targets query as follows
C1: to slice-1
C2: no need to target it will execute in all slices
C3: to slice-2

4. As Jody pointed out, the DistributedPolicy should be such that new C1,C3
instances are stored *only* in slice-1 and slice-3 respectively.



Can't I use slice framework with databases which not have the same structure ?

I have two database with different information and I must to use all these
information ...

How can I make query accross slices ? or accross the two database using openjpa
?

Thanks M. Poddar




Hi,
You can target the query that has Userdb1 to slice ONE only.

Slice, in general, considers that the schema in every slice is identical.



I used Websphere 7.0 ( openjpa 1.2.1 snapshot ) and DB2 UBD 9.1

I want to configure slice describe as follow ( persistence.xml )

<persistence-unit name="persistenceUnit">

<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>

<class>com.ibm.openjpa.slice.test.db1.Userdb1</class>
<class>com.ibm.openjpa.slice.test.db2.Customerdb2</class>

<properties>

<property name="openjpa.BrokerFactory" value="slice" />
<property name="openjpa.slice.Names" value="ONE,TWO"/>
<property name="openjpa.slice.Master" value="ONE"/>
<property name="openjpa.slice.Lenient" value="true"/>

<property name="openjpa.ConnectionDriverName"
value="com.ibm.db2.jcc.DB2Driver" />
<property name="openjpa.ConnectionURL"
value="jdbc:db2://localhost:52000/DB1"/>
<property name="openjpa.ConnectionUserName"
value="db2admin"/>
<property name="openjpa.ConnectionPassword"
value="db2admin,001" />


<property name="openjpa.slice.ONE.ConnectionDriverName"
value="com.ibm.db2.jcc.DB2Driver" />
<property name="openjpa.slice.ONE.ConnectionURL"
value="jdbc:db2://localhost:52000/DB1"/>
<property name="openjpa.slice.ONE.ConnectionUserName"
value="db2admin"/>
<property name="openjpa.slice.ONE.ConnectionPassword"
value="db2admin,001" />


<property name="openjpa.slice.TWO.ConnectionDriverName"
value="com.ibm.db2.jcc.DB2Driver" />
<property name="openjpa.slice.TWO.ConnectionURL"
value="jdbc:db2://localhost:52000/DB2"/>
<property name="openjpa.slice.TWO.ConnectionUserName"
value="db2admin"/>
<property name="openjpa.slice.TWO.ConnectionPassword"
value="db2admin,001" />


<property name="openjpa.slice.DistributionPolicy"
value="org.apache.openjpa.slice.policy.MyUserDistributionPolicy"/>

<property name="openjpa.Log" value="SQL=TRACE"/>

</properties>
</persistence-unit>

I want to use 2 several databases. For testing I build a simple database
structure with one table in each database. Each database is connected to a
slice so, Userdb1 is in slice one and Customerdb2 is in slice two.

When I try to make a simple SELECT udb1.udb1Id, udb1.udb1Name, udb1.udb1Mail
FROM Userdb1 udb1, I have this error : DB2 SQL error: SQLCODE: -204, SQLSTATE:
42704, ...

Slice want to find Userdb1 in slice TWO but this table is in slice ONE only...

How I can do solve this problem ?

Best regards :)







-----
Pinaki Poddar http://ppoddar.blogspot.com/

http://www.linkedin.com/in/pinakipoddar
OpenJPA PMC Member/Committer
JPA Expert Group Member
--
View this message in context:
http://n2.nabble.com/Slice-Error-with-simple-query-%28-Websphere-7.0---DB2-9.1-%29-tp2544575p2546151.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: No table was given for persistent type

Use this project instead: http://filebin.ca/dwjkxk/DavidLeangen.zip On Fri, Mar 27, 2009 at 10:59 AM, Kevin Sutter <kwsutter@xxxxxxxxx> wrote: > Okay, I couldn't resist... I tried your source code and it worked for > me... I did not use the maven plugin for building since I have maven 2.0.8 > and it seems to require 2.0.6. It also looks like you have a special > version of the plugin... Anyway, I skipped the maven plugin. > > I created a simple Eclipse project with your Person and Persister classes. > I also created a PersonTest main test class. I'm using openjpa 1.2.0. I'm > using Postgres, like you have. > > I also modified your test slightly so that I wouldn't hit duplicate key. > > I ran it with both pre-enhancing the Person entity and by using the > -javaagent option. Both of them worked. > > BTW, I found out that our sub-classing support will not even kick in if you > are using "final" types, so you're safe from that perspective. You must be > enhancing somehow or else you would be getting an error message from the > sub-classing support. > > I posted my project here: http://filebin.ca/zuquzp/DavidLeangen.zip > > You have the next move... :-) > Kevin > > > > On Fri, Mar 27, 2009 at 9:42 AM, Kevin Sutter <kwsutter@xxxxxxxxx> wrote: > >> Hi David, >> Thanks for the additional information. A couple of things to comment >> on... >> >> For some reason, you are getting different exception text than the first >> one you posted. This exception text actually points back to your Person >> entity, so that's good: >> >> <openjpa-1.2.0-r422266:683325 fatal user error> >> org.apache.openjpa.persistence.ArgumentException: No table was given for >> persistent type "net.leangen.expedition.openjpa.internal.Person". >> >> Since we seem to be tripping over the tables, is there any chance that >> this problem is related to the other problem you've posted about the Schema >> Tool not generating the tables as expected? From your configuration and the >> call stack, it looks like you are using the SynchronizeMappings property to >> help create the tables. >> >> I see that you have the <enhancer> element specific in your pom.xml. Have >> you ensured that your entities are getting enhanced, either statically at >> build time or dynamically via a javaagent? The property >> openjpa.RuntimeUnenhancedClasses set to "warn" or "unsupported" would help >> isolate this situation. >> >> It looks like our metadata repository is not getting populated correctly >> for this Person entity before we attempt to create the tables. I'm not >> seeing anything in what you have provided that jumps out at me as being a >> problem. >> >> It sounds like you've tried stepping through the code. What about TRACE? >> Sometimes, the Trace output indicates an earlier condition that is now >> affecting the current condition. >> >> If none of this helps isolate the problem, then we might have to actually >> try to reproduce it... :-) Like I said, I don't see anything unique with >> your setup. Pretty vanilla. >> >> Kevin >> >> >> On Thu, Mar 26, 2009 at 8:24 PM, David Leangen <kodo@xxxxxxxxxxx> wrote: >> >>> >>> Thank you, Kevin. >>> >>> >>> On Thu, 2009-03-26 at 09:01 -0500, Kevin Sutter wrote: >>> > Hi David, >>> > I think we'll need a bit more information. >>> >>> Ok, no problem. >>> >>> I kept fiddling, but still no luck. I noticed that when stepping through >>> the code, even with the @Table annotation, for some reason value for >>> "given" is null. >>> >>> Anyway, here goes: >>> >>> Entity >>> _______________________________________________ >>> package net.leangen.expedition.openjpa.internal; >>> >>> import javax.persistence.*; >>> >>> @Entity >>> @Table( name="person" ) >>> public final class Person >>> { >>> private static final long serialVersionUID = 1L; >>> >>> private String sin; >>> private String name; >>> >>> public Person(){} >>> >>> public Person( String aSin, String aName ) >>> { >>> sin = aSin; >>> name = aName; >>> } >>> >>> @Id >>> public String getSin() >>> { >>> return sin; >>> } >>> >>> public void setSin( String sin ) >>> { >>> this.sin = sin; >>> } >>> >>> @Basic >>> public String getName() >>> { >>> return name; >>> } >>> >>> public void setName( String name ) >>> { >>> this.name = name; >>> } >>> >>> @Override >>> public String toString() >>> { >>> return getName(); >>> } >>> >>> @Override >>> public boolean equals( Object o ) >>> { >>> if( this == o ) >>> return true; >>> >>> if( !( o instanceof Person ) ) >>> return false; >>> >>> final Person that = (Person)o; >>> return this.getSin().equals( that.getSin() ); >>> } >>> >>> @Override >>> public int hashCode() >>> { >>> return 17*getSin().hashCode(); >>> } >>> } >>> >>> persistence.xml (edited) >>> _______________________________________________ >>> <?xml version="1.0"?> >>> <persistence xmlns="http://java.sun.com/xml/ns/persistence" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>> version="1.0"> >>> <persistence-unit name="openjpa"> >>> >>> >>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> >>> <class>net.leangen.expedition.openjpa.internal.Person</class> >>> <properties> >>> <property name="openjpa.ConnectionURL" >>> value="jdbc:postgresql://xxxxx/xxxxx"/> >>> <property name="openjpa.ConnectionDriverName" >>> value="org.postgresql.Driver"/> >>> <property name="openjpa.ConnectionUserName" value="xxxxx"/> >>> <property name="openjpa.ConnectionPassword" value="xxxxx"/> >>> <property name="openjpa.Log" value="DefaultLevel=WARN, >>> Tool=INFO"/> >>> <property name="openjpa.jdbc.SynchronizeMappings" >>> value="buildSchema(ForeignKeys=true)"/> >>> </properties> >>> </persistence-unit> >>> </persistence> >>> >>> "main" code >>> _______________________________________________ >>> final EntityManagerFactory entityManagerFactory = >>> Persistence.createEntityManagerFactory( "openjpa" ); >>> >>> final Persister persister = new >>> Persister( entityManagerFactory ); >>> final Person person = new Person( "12345", "David Leangen" ); >>> persister.createPerson( person ); >>> final Collection<Person> people = persister.getAllPeople(); >>> System.out.println("List of all people in db: "); >>> for( final Person nextDude: people ) >>> { >>> System.out.println( nextDude.getName() ); >>> } >>> >>> >>> Thread.currentThread().setContextClassLoader( currentClassLoader ); >>> >>> >>> Persister code >>> _______________________________________________ >>> package net.leangen.expedition.openjpa.internal; >>> >>> import java.util.*; >>> import javax.persistence.*; >>> >>> public class Persister >>> { >>> private final EntityManagerFactory entityManagerFactory; >>> >>> public Persister( EntityManagerFactory anEntityManagerFactory ) >>> { >>> entityManagerFactory = anEntityManagerFactory; >>> } >>> >>> @SuppressWarnings("unchecked") >>> public Collection<Person> getAllPeople() >>> { >>> final EntityManager entityManager = >>> entityManagerFactory.createEntityManager(); >>> final EntityTransaction transaction = >>> entityManager.getTransaction(); >>> try >>> { >>> transaction.begin(); >>> final List<Person> resultList = >>> entityManager.createQuery( "select p >>> from Persona p" ).getResultList(); >>> return resultList; >>> } >>> finally >>> { >>> transaction.commit(); >>> entityManager.close(); >>> } >>> } >>> >>> public void createPerson( Person person ) >>> { >>> final EntityManager entityManager = >>> entityManagerFactory.createEntityManager(); >>> final EntityTransaction transaction = >>> entityManager.getTransaction(); >>> try >>> { >>> transaction.begin(); >>> entityManager.persist( person ); >>> } >>> finally >>> { >>> transaction.commit(); >>> entityManager.close(); >>> } >>> } >>> } >>> >>> >>> pom.xml >>> _______________________________________________ >>> <project> >>> ... >>> >>> <build> >>> <plugins> >>> <plugin> >>> <groupId>org.codehaus.mojo</groupId> >>> <artifactId>openjpa-maven-plugin</artifactId> >>> <!-- use locally patched version for now --> >>> <version>1.1-SNAPSHOT</version> >>> <configuration> >>> <includes>src/main/java/**/*.class</includes> >>> <addDefaultConstructor>true</addDefaultConstructor> >>> >>> <enforcePropertyRestrictions>true</enforcePropertyRestrictions> >>> <schemaAction>add</schemaAction> >>> <toolProperties> >>> <property> >>> <name>addDefaultConstructor</name> >>> <value>true</value> >>> </property> >>> <property> >>> <name>enforcePropertyRestrictions</name> >>> <value>true</value> >>> </property> >>> <property> >>> <name>properties</name> >>> <value>${basedir}/META-INF/persistence.xml</value> >>> </property> >>> </toolProperties> >>> </configuration> >>> <executions> >>> <execution> >>> <id>enhancer</id> >>> <phase>process-classes</phase> >>> <goals> >>> <goal>enhance</goal> >>> </goals> >>> </execution> >>> </executions> >>> <dependencies> >>> <dependency> >>> <groupId>org.apache.openjpa</groupId> >>> <artifactId>openjpa</artifactId> >>> <version>1.2.0</version> >>> </dependency> >>> </dependencies> >>> </plugin> >>> </plugins> >>> </build> >>> >>> </project> >>> >>> >>> Exception >>> _______________________________________________ >>> <openjpa-1.2.0-r422266:683325 fatal user error> >>> org.apache.openjpa.persistence.ArgumentException: No table was given for >>> persistent type "net.leangen.expedition.openjpa.internal.Person". >>> at >>> >>> org.apache.openjpa.jdbc.meta.MappingInfo.createTable(MappingInfo.java:437) >>> at >>> >>> org.apache.openjpa.jdbc.meta.ClassMappingInfo.getTable(ClassMappingInfo.java:241) >>> at >>> >>> org.apache.openjpa.jdbc.meta.ClassMappingInfo.getTable(ClassMappingInfo.java:259) >>> at >>> >>> org.apache.openjpa.jdbc.meta.strats.FullClassStrategy.map(FullClassStrategy.java:71) >>> at >>> >>> org.apache.openjpa.jdbc.meta.ClassMapping.setStrategy(ClassMapping.java:377) >>> at >>> >>> org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:55) >>> at >>> >>> org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:333) >>> at >>> >>> org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:662) >>> at >>> >>> org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:549) >>> at >>> >>> org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308) >>> at >>> >>> org.apache.openjpa.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:285) >>> at >>> org.apache.openjpa.jdbc.meta.MappingTool.getMapping(MappingTool.java:676) >>> at >>> >>> org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(MappingTool.java:748) >>> at >>> org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:646) >>> at >>> >>> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:153) >>> at >>> >>> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:119) >>> at >>> >>> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:189) >>> at >>> >>> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142) >>> at >>> >>> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192) >>> at >>> >>> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145) >>> at >>> >>> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56) >>> at >>> >>> net.leangen.expedition.openjpa.internal.Persister.createPerson(Persister.java:45) >>> at >>> >>> net.leangen.expedition.openjpa.internal.Activator.start(Activator.java:58) >>> at org.eclipse.osgi.framework.internal.core.BundleContextImpl >>> $2.run(BundleContextImpl.java:1009) >>> at java.security.AccessController.doPrivileged(Native Method) >>> at >>> >>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:1003) >>> at >>> >>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:984) >>> at >>> >>> org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346) >>> at >>> >>> org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:265) >>> at >>> >>> org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:257) >>> at >>> >>> org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start(FrameworkCommandProvider.java:257) >>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>> at >>> >>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >>> at >>> >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >>> at java.lang.reflect.Method.invoke(Method.java:585) >>> at >>> >>> org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:150) >>> at >>> >>> org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:302) >>> at >>> >>> org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(FrameworkConsole.java:287) >>> at >>> >>> org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConsole.java:223) >>> at java.lang.Thread.run(Thread.java:595) >>> >>> >> >

Next Message by Date: click to view message preview

Re: 'Masking' fields in an Entity

Hi, > I have a whole hierarchy of entities that I am transforming using JAXB > to send XML to a browser client. But, the amount of detail that I am > sending as XML changes depending on the type of request. OpenJPA's dynamic FetchPlan is the correct solution for such use case. With FetchPlan you can control the exact details that you need in the entity classes that are to be sent to the browser client. > I have been making several entity classes to > describe the same database table. Not needed if you consider using FetchPlan. Hello all, I have what may be a strange requirement (I guess you will have to decide on that). But, there is a fairly long amount of background before you get to my actual question. Background - I have a whole hierarchy of entities that I am transforming using JAXB to send XML to a browser client. But, the amount of detail that I am sending as XML changes depending on the type of request. For example (simplified): A project has many details Each detail contains a component Each component contains several attributes Sometimes I want to be able to send back only the XML for the project (without any of its children) and sometimes, I want to send back the whole structure. The reason for this is that a fully populated entity can become extremely large (sometimes several Mb) - and sending that much much information as the response to an AJAX call ends up killing performance. To accomplish this, I have been making several entity classes to describe the same database table. 'Project' is the full hierarchy and 'FlatProject' is the project and its details - without the components. But, to support the various scenarios for exactly how much detail I want to transmit has let to a lot of duplication on entities (each a partially defined versions of the real data structure). Question - Inheritance does not really satisfy my need. In my database, everything matches the 'fully defined' version of my entities. So, is there a way to 'mask' my entities so that I only have one entity class that actually refers to the database table but several masks that limit how much of the data is visible? Hopefully I am not the first person to have a need like this. Thanks in advance, Jay ----- Pinaki Poddar http://ppoddar.blogspot.com/ http://www.linkedin.com/in/pinakipoddar OpenJPA PMC Member/Committer JPA Expert Group Member -- View this message in context: http://n2.nabble.com/%27Masking%27-fields-in-an-Entity-tp2545263p2546173.html Sent from the OpenJPA Users mailing list archive at Nabble.com.

Previous Message by Thread: click to view message preview

Re: Slice Error with simple query ( Websphere 7.0 & DB2 9.1 )

Hello, Jaidge Could you post what your org.apache.openjpa.slice.policy.MyUserDistributionPolicy class looks like? That is the essential class that tells OpenJPA's slice plugin how to divvy work up between the slices. It's possible that a bug in this class might have caused OpenJPA to refer to the wrong slice. Best Regards, Jody Grassel On Fri, Mar 27, 2009 at 10:39 AM, jaidge <jaidge@xxxxxxxxxxx> wrote: > > Can't I use slice framework with databases which not have the same > structure ? > > I have two database with different information and I must to use all these > information ... > > How can I make query accross slices ? or accross the two database using > openjpa ? > > Thanks M. Poddar > > > > > Hi, > You can target the query that has Userdb1 to slice ONE only. > > Slice, in general, considers that the schema in every slice is identical. > > > > I used Websphere 7.0 ( openjpa 1.2.1 snapshot ) and DB2 UBD 9.1 > > I want to configure slice describe as follow ( persistence.xml ) > > <persistence-unit name="persistenceUnit"> > > > <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> > > <class>com.ibm.openjpa.slice.test.db1.Userdb1</class> > <class>com.ibm.openjpa.slice.test.db2.Customerdb2</class> > > <properties> > > <property name="openjpa.BrokerFactory" value="slice" > /> > <property name="openjpa.slice.Names" > value="ONE,TWO"/> > <property name="openjpa.slice.Master" value="ONE"/> > <property name="openjpa.slice.Lenient" > value="true"/> > > <property name="openjpa.ConnectionDriverName" > value="com.ibm.db2.jcc.DB2Driver" /> > <property name="openjpa.ConnectionURL" > value="jdbc:db2://localhost:52000/DB1"/> > <property name="openjpa.ConnectionUserName" > value="db2admin"/> > <property name="openjpa.ConnectionPassword" > value="db2admin,001" /> > > > <property > name="openjpa.slice.ONE.ConnectionDriverName" > value="com.ibm.db2.jcc.DB2Driver" /> > <property name="openjpa.slice.ONE.ConnectionURL" > value="jdbc:db2://localhost:52000/DB1"/> > <property > name="openjpa.slice.ONE.ConnectionUserName" value="db2admin"/> > <property > name="openjpa.slice.ONE.ConnectionPassword" value="db2admin,001" /> > > > <property name="openjpa.slice.TWO.ConnectionDriverName" > value="com.ibm.db2.jcc.DB2Driver" /> > <property name="openjpa.slice.TWO.ConnectionURL" > value="jdbc:db2://localhost:52000/DB2"/> > <property name="openjpa.slice.TWO.ConnectionUserName" > value="db2admin"/> > <property name="openjpa.slice.TWO.ConnectionPassword" > value="db2admin,001" /> > > > <property name="openjpa.slice.DistributionPolicy" > value="org.apache.openjpa.slice.policy.MyUserDistributionPolicy"/> > > <property name="openjpa.Log" value="SQL=TRACE"/> > > </properties> > </persistence-unit> > > I want to use 2 several databases. For testing I build a simple database > structure with one table in each database. Each database is connected to a > slice so, Userdb1 is in slice one and Customerdb2 is in slice two. > > When I try to make a simple SELECT udb1.udb1Id, udb1.udb1Name, > udb1.udb1Mail FROM Userdb1 udb1, I have this error : DB2 SQL error: > SQLCODE: -204, SQLSTATE: 42704, ... > > Slice want to find Userdb1 in slice TWO but this table is in slice ONE > only... > > How I can do solve this problem ? > > Best regards :) > > > > > -- > View this message in context: > http://n2.nabble.com/Slice-Error-with-simple-query-%28-Websphere-7.0---DB2-9.1-%29-tp2544575p2544909.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > >

Next Message by Thread: click to view message preview

'Masking' fields in an Entity

Hello all, I have what may be a strange requirement (I guess you will have to decide on that). But, there is a fairly long amount of background before you get to my actual question. Background - I have a whole hierarchy of entities that I am transforming using JAXB to send XML to a browser client. But, the amount of detail that I am sending as XML changes depending on the type of request. For example (simplified): A project has many details Each detail contains a component Each component contains several attributes Sometimes I want to be able to send back only the XML for the project (without any of its children) and sometimes, I want to send back the whole structure. The reason for this is that a fully populated entity can become extremely large (sometimes several Mb) - and sending that much much information as the response to an AJAX call ends up killing performance. To accomplish this, I have been making several entity classes to describe the same database table. 'Project' is the full hierarchy and 'FlatProject' is the project and its details - without the components. But, to support the various scenarios for exactly how much detail I want to transmit has let to a lot of duplication on entities (each a partially defined versions of the real data structure). Question - Inheritance does not really satisfy my need. In my database, everything matches the 'fully defined' version of my entities. So, is there a way to 'mask' my entities so that I only have one entity class that actually refers to the database table but several masks that limit how much of the data is visible? Hopefully I am not the first person to have a need like this. Thanks in advance, Jay
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by