Pablo Marmol

Greenhorn
+ Follow
since Aug 23, 2010
Merit badge: grant badges
For More
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 Pablo Marmol

Hi Everyone,

I'm using Liferay in a project and customer has requested me a new functionality: They want to show different content depending on the IP address of the client. My customer has different ip ranges for his clients, let say range 1, range 2, range 3. When a client points his/her browser to the main page of my customer's site, a page for range 1, 2 or 3 should be shown if the client has an ip address in the range 1, 2 or 3.
My customer has apache as front-end, and weblogic with liferay as a back-end. I suppose that if liferay tries to obtain the client ip address, probably the obtained ip would be an apache ip, so maybe this approach won't work. Another approach could be to use apache redirecting rules (that is, identifying the source network in apache and appending certain parameter to the URL for weblogic).
Could you help me? Please, i need only a few comments about this, a link or something. I don't know if this is an usual requirement, but i'm pretty sure that someone has faced this challenge before me.

Thank you very much in advance.
11 years ago
Solved.

Add this to persistence.xml:
<properties>
<property name="openjpa.jdbc.SchemaFactory" value="native(ForeignKeys=true)"/>
</properties>

Enjoy.
More info:

The code is executed within an EJB, using EntityManager and container-managed transactions.
Using Postgresql is the same.
The code works on glassfish3 adding "allocationSize = 1" to the "@SequenceGenerator" annotations. But in WLS 10.3.4 don't works. Glassfish3 comes with JPA2, and WLS 10.3.4 only JPA1, but i'm not using anything of v2.

searching... (thanks in advance)
Hello!

I have a simple issue about parent/child relations. Something is wrong when i persist three instances at same transaction, that is, one child and two parents. The child have ManyToOne relations to the parent1 and the parent2, and the two parents have one OneToMany relation (each one) to the child. The child table have two foreign keys to its parents. This is the code:

Parent1:


Parent2:


Child:


And this is the code that use the entities:


In my investigation about this i find that this works when the child have only one parent.

I try another way: I drop de FK constraints in the database, then i execute the code, and then i recreated the FK constraints... and voila!!! no errors creating the FK constraints ?¿?¿?¿?¿? That signals that the data is right, but anything is wrong and i dont understand... Could you help me please?

I use java 6, weblogic 10.3.4 (jpa 1 i think), oracle 11.

Thank you very very much... i'm obfuscated.
Hi!

I don't understand this. I wrote the code and java.exe throws a compiler error saying that the method call is ambiguous... Why?


On the other hand, there is no such relationship between add(int, long, long) and add(long, int, int) - you can both find a parameter list that is valid for the first but not the second, *and* the other way round. Therefore your call with three int parameters was ambigous.



The call doIt(1,2,3) is (in my opinion) valid for add(int, long, long) and for add(long, int, int), but the second "add" is more specific than first, because the first "add" needs two int to long conversions, and the second "add" only needs one int to long conversion... i think... or not?

I am and and

Thank you very much in advance!
13 years ago

I don't think so!!! I also cleared SCJP 6.0 exams and there were 2 to 3 questions in the exam. You may or may not get question in the exam, but if you encounter it then it will affect your marks if you don't prepare for it.



That's what i see in K&B.... Maybe someone could explain what kind of questions about serialization will we find in the exam!!
The local variable is "value", but the StringBuffer is global to all threads calling that method. So while StringBuffer is thread-safe, the method "attachThisVal" isn't. For example, is posible an output like "Thread-1Thread-2Thread-3valuevaluevalue", if there is three threads and the value of parameter "value" is "value".

I hope this helps...
But they can ask us things like execution of constructors on serialized classes, i think...
Hi Chris!

Normally, a monitor is on a high abstraction level than a lock. You could use a lock to control the access of a thread to a single resource. You open the lock, your thread enters, your thread exits, and you close the lock. A monitor usually is a more sophisticated thing that allows you things like readers-writers problem, producer-consumer problem or any other synchronization problem (Yes, a lock could work with this problems but in a low abstraction level. Yes, you could use machine-code too (a lower abstraction level)).

Maybe it's like difference between an array (for example) and a hashtable: You can use an array to implement a hashtable, but it's very difficult to implement an array using a hashtable. In fact, almost every monitor uses one or more locks.

I hope this helps you!
What's the problem? (I think i'm seeing that you're posted)

Hmm... program runs correctly, even if you remove "super" in getCountry method...

Pradeep Kr wrote:

Pablo Marmol wrote:

Well, how many i's I have?



Logically to me it looks like for every loop iteration new i (variable) is created and as soon as that iteration finish, i (variable) become out of scope. If you were asking how many i (variable) is created? one for each iteration on stack, but it is not like one on top of another. It is like one created then popped out then new created.

push(i) for first iteration
pop() as first iteration finish
push(i) for second iteration
..
..
and so on

I am not sure I answered your question but tried to put some thought to clear your doubt, If I did.



Ok. Understood.

The "push, pop, push, pop, ..." was the key for me to understand that. But that don't seem to be exactly like you say (please excuse me, the explanation was perfect in a conceptual sense): I have write code declaring variable i within loop, and declaring variable i out of loop, and those 2 programs take the same time (aprox). For example, a loop with 1e8 iterations take the same time declaring variables within loop and declaring out. I think there is some optimization when you declare variables within loops. I will drop an eye to see the JLS.

Thanks to everybody, thanks for the reply and thanks for my welcome to the ranch!!!

PD: If you want, I'll post the 2 programs, i haven't do because they are trivial for programmers like us!!!
Hello everybody! this is my first message.

I've been studying for SCJP for a few months, I have ~ 10 years of experience in Java but now i want to achieve this certification.

I have one stack-related question:

What if I declare a variable in a loop body? It creates an instance in every iteration of loop? (Note, I say variable, not object):


Well, how many i's I have? Yes, I have one. But something I remember says to me that this is not very well practice (I remember C++, I think in this language
this will create an instance of i every iteration!!). Then, this is my explanation: I have only one i, but the stack is filling with int's that nobody never will use, isn't it?

PD: Excuse my bad english, feel free for correct me!! I expect I explained this not very bad but...

Thank you, very much!!!