Fabrizio Pia

Greenhorn
+ Follow
since Apr 24, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Fabrizio Pia

Hello. Here my problem.

First object is named Persona.
Second object is named Societa. There is a relation many for Persona and one for Societa.
Societa has two properties, let's call them "des" and "desIndirizzo".

I've a spring form (<form:form>) with modelattribute="person" in order to change some person properties submitting such form.
Here an example:



From this form I need to change not only Persona's properties but also Societa's properties.

I think to write
and


This doesn't work.
I get "TransientObjectException: object is an unsaved transient instance - save the transient instance before merging: net.coop.domain.Societa"
Anyway, in the browser I can see both the input texts correctly filled with the right values!

My questions are:
First: Because I set modelattribute="persona", I was expecting that "societa.des" is the same as "persona.societa.des". After a debug I see that "societa.des" is the same as "persona.des". Obviously this doesn't exists! Why? The only manner to work is to write

But in this case a new question arises:
Second: How can I relate the first <form:input> in order to submit the Societa's "des" property and the second <form:submit> to the Societa's "desIndirizzo" property?

Third: More in general, is it possible to change properties of a object (in my case Societa) from a form of a related object (Persona)?


I also wrote and registered a property editor like this:



Can anyobe help me please?
Thank you

Fpia
14 years ago
Hello.
Hibernate and Spring are running.
I've two tables in a one-to-many relation.
When I try to remove an object (from the "many" side) I get the message "IllegalArgumentException: Removing a detached instance"
I've already read some older topics. They suggest that when you have a detached object, you need to relaod it in a new hibernate session. It is possible to do that with a merge operation.

I keep on getting the same error. I don't know what else to do!!

Here my code:


and here the relations between objects:



and



Please, can anyone help me?
thank you
fpia
Thank you James.

Well, I'm working with MySQL and the engine is MYISAM. It seems that flush commits the transaction!! Mmmhhh... is this behavior right?
Now, I tried with InnoDB engine and flush works well. It does not commit data. That is what I was expecting.

Thank you
Fabrizio
Hello. Here the problem:
JPA and EntityManager is the environment.

Inside a transaction I want to save an Entity object. I do it with entityManager persist() method.
Now, inside the same transaction (and without any commit() command), I need to get the ID of the record related to the last object just inserted.
I need the last record ID because I want to write it in another table but inside the SAME transaction in order to handle the right IDs relations among tables.
I can't get the ID because any data hasn't been committed. The DB can't "see" data.
The way is to run the flush() method. But in such manner all the data are flushed to the DB.
I don't want to do that, because my transaction (in terms of ACID model) is not ended. More changes I need to do before closing the transaction.

How can I do this?
Follows a brief code example:



As you can see, I need to flush the data in order to get the ID. But in such way I need to open another transaction to manage other tables.
Can anyone help me?

Thank you
Fabrizio
Hi all,

here my problem:
JPA
I've a composite key (4 columns in the table are my key) and related "embeddable" class (named "RelazId") with 4 properties.



Another class (named "Relaz") has RelazId as its own ID key.



Everything seems to work but:

As I wrote above I've 4 columns in the RELAZ table. I need to select all the records in which three columns have fixed values.
Something like SELECT * FROM RELAZ WHERE col1 = x AND col = Y and col3 = Z. All the values in the forth column are good.

In order to work with JPA objects, I need to make a RelazId object and selecting all the Relaz objects.

For example:


Then:


I don't want to set the fourth column because I want to delete all the records with fixed values just on the first three columns.
But obviously java writes that an object RelazId with just three setted properties is not good.

Which is the right way in oder to select just some records based on a columns subset?

Thank you
Fabrizio
Hello. I'm new to EJB and overall JNDI!!
I'm developing an application client that should call a remote EJB method.
EJB (ver 2.1) is running on glassfish server. Using netbeans 6.1, it makes two EJB modules, related to the client and to the EJB.
I'd like to simulate a client that call an EJB located on a remote server.

Two problems:
1) I got the message "This bean [ConverterBean] has no ejb reference by the name of [ejb/ConverterBean]". My sun-ejb-jar.xml is


and my ejb-jar.xml is


What is wrong?

2)The second message I got is: Invalid Deployment Descriptors element jndi-name value corbaname:iiop:remotehost:3700#ejb/ConverterBean"

But reading the documentation it seems correct. Anyway my sun-application-client is



Can anyone help me?
thank you.
F.
Ops! Yes you're right!
Now it works.

But anyway the LabelValueBean does a very strange effect...

Now my code is



The menu should have three options "Mr. White", "Mr...", while in my menu I see "LabelValueBean[Mr. White,1]", then as second option "LabelValueBean[Mr. Gree, 2]"...

The add method takes the "new" argument as a string nut the code should be correct!! Do I need to change the html ption configuration?

Can you help me please?
Thank you

Fpia
17 years ago
Hi!
thank you. I understand what you mean.
Well, I did that, but now I got:

java.lang.NullPointerException
at com.test.struts.users.getUsers(users.java:12)

This means that it is the same problem. The collection is not yet ready. Right?
There are no problems in the code or jsp, but how the entities (action, form, jsp) are related among them and the order how they are made. Infact you wrote "The way you've got it set up...". Is there another way to avoid this problem? I mean, in order to have the correct order of the objects definition, do I need to change something in the main structure of my application?

Anyway I'm very surprised, beacuse I learnt a base struts application (like mine) is made of a jsp, a form and an action. Normally it works good! What are the changes I need to do?

Thank you for your suggestions.
Fpia
17 years ago
Ok I tried, but I got
"Failed to obtain specified collection"

Any suggestion please?
Fpia
17 years ago
Hello. I'm trying to make a menu selection with struts 1.1 but I get the message "Property list returned a null value".
Please, where is the problem??

Here the code:


--------SelectionForm.java-------------



-----------SelectionAction.java---------------



I write also my Model code:

------users.java-----



Here my struts-config.xml file:


About html ption tag, I also tried with the collection attribute, but I got the message "Cannot find bean under name list".

Can anyone help me please? I'm spending too many days on this problem!!

Thank you in advance.

fpia
17 years ago