Ram Raju

Greenhorn
+ Follow
since Mar 11, 2003
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 Ram Raju

Well this is new development. Data model changes are still welcome.

my goal -> [B]
------------------------------------
id | value | type | a_id
------------------------------------
1 | alpha | x | 1
2 | beta | x | 1
3 | gamma | y | 1

and hibernate should take care of populating the object x/y based on the type. I need to know if I can do this and how to write the mapping for that.

Thanks
Ram
I agree with you. So can you please suggest on how to implement this.
Paul,

I am not sure if I described my problem correctly. I want the values in x, y, z to be different.

x -> "alpha", "beta"
y -> "gamma"

but with current mapping, all values are getting loaded into all the attributes.

x -> "alpha", "beta", "gamma"
y -> "alpha", "beta", "gamma"

Since the database structure for table B is

------------------
id | value | a_id
------------------
1 | alpha | 1
2 | beta | 1
3 | gamma | 1

How would it know what to load in x and what to load in y.
Paul,

Thankyou for the response. I have a problem with the mapping I posted. All the entries in table B for a particular A are loaded into all the sets (x, y, z). I guess this is because there is nothing in the mapping to diffrentiate b/w various sets.
I have multiple one-to-many relationships to the same class from a class. Is there a way to Map it?

<class name="A" table="A">
...
<set name="x">
<key column="a"/>
<one-to-many class="B"/>
</set>

<set name="y">
<key column="a"/>
<one-to-many class="B"/>
</set>

<set name="z">
<key column="a"/>
<one-to-many class="B"/>
</set>
</class>
--------------------------------------------
class B {
public String value;
}
--------------------------------------------
I just use B to save a list of options for different attributes of A. Can I map using one generic class B or do I need to have a different class for each attribute in A (Bx, By, Bz). Is there a better way to address the whole issue?

Thanks in advance
Ram
[ March 14, 2006: Message edited by: Ram Raju ]
Thankyou for your replies. The more I think about it, the in-memory sounds like a bad idea, particularly when the system crashes and there is no way to restore the lost data. I use hibernate for ORM and let spring handle the connections. So not much I can do there. Will profile the code. Thanks for all the comments.
18 years ago
Thankyou for your replies. I recieve data as messages over various channels which I persist in a database. So I dont know when the next may come if it comes. When I recieve a burst (say > 500) of messages, the write to database lags significantly (takes a couple of mins to write 500 times to MySql).
18 years ago
I have an application which recieves bursts of data that it has to update to a database. The frequent calls are getting expensive. I want to update to an in-memory database and do a batch update to the on-disk database from in-memory, based on size/no of records or time. I am hoping this would greatly improve the performance. Any suggestions or can anyone point me to a similar implementation. Any help on how to proceed is appreciated.
18 years ago
Ok. I found what was causing Stack overflow.

I started development using AppFuse and was extending BaseObject in all my model objects. For those who havent looked at appfuse, BaseObject is just a Serializable bean which overrides toString, equals and hashCode methods.

When I extended BaseObject in both parent and child and tried to set one in the other, something in the hashCode method did not like it. When I stopped extending BaseObject in child, everything was ok.

Thanks David & Clemens for helping me out.
David:

The java.lang.StackOverflowError occurs in JUnit test.

The method in EventDAO impl.


Clemens:
I am adding the EventAttribute to set and adding the set to event. I am also setting the event in the EventAttribute.



I am adding the EventAttribute to set and also setting the Event in the event attribute. Is this circular assignment causing the overflow.

If I dont do
- s.add(ea);
the event is created, but the attributes table is empty.

[ March 15, 2005: Message edited by: Ram Raju ]
[ March 15, 2005: Message edited by: Ram Raju ]
Hi,

I am trying a one-to-many bidirectional mapping.
An Event has multiple EventAttributes.

Event event = new Event();

Set s = new HashSet();
EventAttribute ea = new EventAttribute();
ea.setEvent(event);
s.add(ea);

event.setEventAttributes(s);

dao.saveEvent(event);

Mapping:

<class name="Event" table="event">
<id name="eventId" column="event_id" unsaved-value="0">
<generator class="increment"/>
</id>
<set name="eventAttributes" table="event_attribute" lazy="false" cascade="all" inverse="true">
<key column="event_id" />
<one-to-many class="EventAttribute"/>
</set>
</class>
<class name="EventAttribute" table="event_attribute">
<id name="eventAttributeId" column="event_attribute_id" unsaved-value="0">
<generator class="increment"/>
</id>
<many-to-one name="event" column="event_id" class="Event" not-null="true"/>
</class>

This causes a stack overflow error.!!

I am stuck. Please help.

[ March 14, 2005: Message edited by: Ram Raju ]
[ March 14, 2005: Message edited by: Ram Raju ]
For some reason <var-name>datePattern</var-name> does not work but
<var-name>datePatternStrict</var-name> works. Any ideas anybody?

Thanks
19 years ago
Just for a change guys.
21 years ago
By NOAM CHOMSKY, longtime political activist, writer and professor of linguistics at MIT.

"The bin Laden network, I doubt if anybody knows it better than the CIA, since they were instrumental in helping construct it. This is a network whose development started in 1979, if you can believe President Carter’s National Security Advisor Zbigniew Brzezinski. He claimed, that in mid–1979 he had instigated secret support for Mujahedin fighting against the government of Afghanistan in an effort to draw the Russians into what he called an “Afghan trap,” a phrase worth remembering. He’s very proud of the fact that they did fall into the Afghan trap by sending military forces to support the government six months later, with consequences that we know. The U.S., along with Egypt, Pakistan, French intelligence, Saudi Arabian funding, and Israeli involvement, assembled a major army, a huge mercenary army, maybe 100,000 or more, and they drew from the most militant sectors they could find, which happened to be radical Islamists."
"Many of the harsh, brutal, oppressive regimes are backed by the U.S. That was true of Saddam Hussein, right through the period of his worst atrocities, including the gassing of the Kurds. U.S. and British support for the monster continued. "
**Just in case you didnt know, Only six months after the slaughter at Halabja (5000 Dead), the White House lent Saddam Hussein another billion dollars. And in 1991, at the end of the Gulf war, US troops stood idly by while Saddam's presidential guard ruthlessly suppressed the popular uprising by the Kurds for which the American president had himself called.
"Madeleine Albright’s infamous statement about how maybe half a million children have died, and it’s a high price but we’re willing to pay it, doesn’t sound too good among people who think that maybe it matters if a half a million children are killed by the U.S. and Britain."
**Somebody needs to look at their foriegn policy.
21 years ago