Brian Smith

Ranch Hand
+ Follow
since May 20, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brian Smith

I am trying to use a @NamedNativeQuery which return an intersect query.

Here is the mapping I was trying



Eventhough this query returns all the columns of a single table, its treated as scalar because of the intersect operator. Here is the exception I got



How can I map this query to a entity? Will something like this work? Also how do I handle the foreign key that is mapped (in bold)? Do I need to map the related entity in the resultSetMapping as well? When this resultset it returned will the entities be managed? Or will I have to merge them?


Here is the entity definition



Thanks!
[ September 26, 2007: Message edited by: Brian Smith ]
I have a m:n relationship represented by two m:1 relationships. These correspond to intersections and streets. I have a street entity, an intersection entity and an intersectionStreet entity.

I am trying to find all intersections given two of the streets that participate in that intersection.

For example - Find the intersection where Main St. and Wall St. intersect

Finding an intersection based on one street is easy

Select ist.intersection From IntersectionStreet ist Where
ist.street = :street

But here I am looking for an intersection given two of the above queries given two different streets. Is such a thing possible using ejb ql? I think my last hope would be an Oracle Native query using their SQL Intersection functions or a Union. I don't want duplicate results.

Thanks
[ September 24, 2007: Message edited by: Brian Smith ]
I have an entity (InvalidAddress) with a many to one relationship with another entity (ServiceRequest). I am trying to add an InvalidAddress entity to the InvalidAddressCollection owned by ServiceRequest



I am getting a NPE because serviceRequest.getInvalidAddressCollection() is returning null when there are no related InvalidAddress entities. I know this makes sense but it seems like a waste to have to do this before I add any related entity to any collection



Is this very repetitive boiler-plate required when working with collections?

It would seem like the EntityManager should initialize the Collection and just return an empty list instead of a null list. Or is that up to me when I implement the getter on ServiceRequest?

Thanks for any advice.
[ July 23, 2007: Message edited by: Brian Smith ]
I was able to test this today, for anyone who cares...

When a managed entity is set to null, the underlying data model does not change. The entity becomes detached and dereferenced like any other object.
Ok, this should be pretty basic but was unable to find an answer via google.

What happens when you null an entity when using an Extended PC? I would think that it does not alter the underlying data model at all and should just act like any other pojo. In order to affect the data model you would have to call an EntityManager method like .remove(), correct?

It is just confusing to me because you can update an entity just by calling setter methods without calling any entity manager methods.

Example



The underlying data row for foo with id = "SomeId" should be unchanged?

I would test this myself but do not have the facilities to do so at the moment.

Thanks.
[ July 11, 2007: Message edited by: Brian Smith ]
I am a little confused when it comes to mapping inheritance in JPA (Hibernate Annotations)

I have an entity (AddressLookup) which has a subclass (Landmark). The parent entity is related to another entity (ServiceRequest) OneToMany.

I am using the Table per subclass (JOINED) mapping pattern.

AddressLookup


Landmark


ServiceRequest



Now when writing a query how do I refer to Landmarks via ServiceRequests?

In order for the following to be valid, should I map Landmark to AddressLookup OneToOne?

Landmark landmark = serviceRequest.getAddressLookup.getLandmark();

It is not a problem going the other way since Landmark inherits getServiceRequestCollection from AddressLookup but ServiceRequest knows nothing of the subclass Landmark.

Thanks for any help.

-Brian
Thanks for the reply Mike. I tried that approach initially, (except TABLE_PER_CLASS) The problem I could not get past was the fact that a user can enter the address directly into ServiceRequest as an alternative to selecting a landmark or intersection. So I needed the Address Keys on ServiceRequest as well. So I was maintaining the Address on ServiceRequest as well as on the Landmark/Address relationship. It just seemed ugly to me. The other problem is that an Address can have many landmarks/intersections associated with it. So I would have a 1-M relationship between Address and "AddressReference". My end goal is to be able to view all ServiceRequests linked to an address regardless of how the user entered the address (via address, landmark, or intersection). So I need a way to maintain a 1-M between ServiceRequest and Address as well be able to get to the specific Landmark/Intersection that was entered when viewing the ServiceRequest.

Thanks again
I have a new data model that I am creating to link to an existing legacy database. The legacy system contains address and geographical information.

The new system is a Service Request system that needs to tie into the address data from the legacy system.

The users have asked to be able to look up and enter service requests via city landmarks and also intersections.

So I have a table (Address) that is from the legacy system (it has compound keys, yuck I know)

Address Table
HouseNum - pk
HouseSuffix - pk
Street - pk
CityBlock - pk
ParcelNumber - pk

Now I have a Landmark table and Intersection table that both need to relate to the address table via Many to One (since the same relationship exists, I will use Landmark for the example)

Landmark Table
LandmarkID - pk
LandmarkName
{keys from Address} - fk

The Service Request table must relate to the Address table (M-1) in order to get all of the geo spacial data and validate addresses against the legacy system. The users can either enter an address directly, choose a landmark (which relates to an address), or choose an intersection (which relates to an address), but never have both an intersection and an address.

ServiceRequest Table
RequestID - pk
{keys from Address} - fk
AddressTypeID - fk (indicates "landmark", "intersection", "address", etc)

The problem comes in when I need to know which landmark was chosen when entering the ServiceRequest. Based on the AddressTypeID I will know whether a landmark was chosen but not necessarily which one. I really don't like the idea of storing the LandmarkID on the ServiceRequest table since I would also need fields for intersection and whatever other future ways to categorize the address and it would create a nice big circular relationship between Landmark, Address, and ServiceRequest.

So to recap here is the structure

Address 1<---->M ServiceRequest
Address 1<---->M Landmark
Address 1<---->M Intersection

A Service Request will either have an address, landmark, or an intersection or neither (never more than one), how do I avoid having LandmarkID and IntersectionID stored directly on ServiceRequest?

Is there any other way I can design this so I will know which landmark was entered when viewing the ServiceRequest? The only table I don't have control over is Address.
[ June 28, 2007: Message edited by: Brian Smith ]
Ok this compiles (Java 1.5)

15 years ago
I don't know if it compiles, it was just "air code" to convey my question. Yes that answers my question, thanks. I didn't think it through enough before I posted. I was getting confused between setting an object reference to null and setting the value of the object to null. The answer is obvious now, Thanks.

-Brian
15 years ago
I would have to disagree with the previous poster about Eclipse, while it (as well as Netbeans, JDeveloper, IDEA, etc) are great pieces of software don't get me wrong, but if you are serious about learning the Java language and core APIs I would stick to something simple like TextPad or something that does not write code for you. Just a simple text editor with syntax highlighting. All the bells and whistles of a full IDE will just gum up the works for now in terms of learning and getting comfortable with Java.
15 years ago
This is just a general question

Is this valid?



Is the element o in the arrayList also dereferenced when I set o = null? Or is the object copied when added to the list?

Thanks
15 years ago
I am not sure if this makes a difference but it may help to name your var something other than "person" since that is also the name of your managed bean.
15 years ago
JSF
Just to elaborate a little more, Navigation in JSF is handled by navigation rules that are defined in faces-config.xml.

They look something like this.



outcome1 and outcome2 are Strings that are returned by a method that your commandButton, commandLink, etc (whatever causes a form submit) on your page are bound to via an action argument. If neither of the <from-outcome> conditions are met, the original page is redisplayed.


[ October 04, 2006: Message edited by: Brian Smith ]
15 years ago
JSF
I am trying to use a managed property list-entries to initialize a List that an f:selectItems is bound to.

<f:selectItems value="#{RowsPerPage.rows}"/>

Here is the managed bean from faces-config


Here is the class



Here is the stack trace

[ October 04, 2006: Message edited by: Brian Smith ]
15 years ago
JSF