Tony Evans

Ranch Hand
+ Follow
since Jun 29, 2002
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
6
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tony Evans

Hi.

I have run profiler, and have a memory leak java.lang.ref.Finalizer, the problem is, I dont have any methods that overwrite the finalised method.  And according to everything I have read so far, its the only way to cause a java.lang.ref.Finalizer, memory leak.

Thanks for any help.
6 days ago
There doesnt seem to any real documentation. I have tried to use classLoader. but that only works in testing.
2 months ago
I have a method that create a output stream


I have  a method that calls it

At System.out.println(); output contains data.
But when I call handleRequest



output.toString() returns a null.

outputStream is an object, so I though I could treat it as one when passing it around as an object.

Thanks for any help
5 months ago
Ok thanks, I was thinking that remainder was the same as modulas % but Its not.
1 year ago
Hi

I am playing around with dividing a BigDecimal


returns
Devided   25.00
Remainder 0.40

Should it not return same as modulas
Devided   25.00
Remainder 0.10
1 year ago
One to one and one to many relationships, if a parent has been deleted, you can set  orphanRemoval true. Will delete the orphan child.

But it seems there is to no way within JPA to remove the orphan for a many to many parent.
I feel the best way is to periodically run amother programme on the DB itself dedicated to removing orphans

Is this the best possible soultion.
That is roughly what I have done. I follow MVC. I have a control layer, a service layer and a repository layer, extending JPARepository. I dont get this problem using Hibernate session factory directly. I guess its one of those things, i will have to play around with, to get working.

Thanks for the reply. Its always good to discuss design, which si just as importannt as coding/
You have set up your session factory in your context.xml

why dont you pass that into your repository and then create your hibernate  sessions  that way.


Then in your repository
[code]
public class FundRepositoryImpl extends MappEntitiesAbstract implements FundRepository {

private SessionFactory sessionFactory;

private static final Logger logger = LoggerFactory.getLogger(FundRepositoryImpl.class);

public void setSessionFactory(SessionFactory sessionFactory) {
       this.sessionFactory = sessionFactory;
   }
   
@Override
public List<FundPOJO> findFunds(List<Long> fundIds) {
Session session = this.sessionFactory.getCurrentSession();
Cache cache = sessionFactory.getCache();
Transaction tx = session.beginTransaction();
Query res = session.createQuery("FROM Fund f WHERE f.fundId IN :fundIds").setParameterList("fundIds", fundIds);
List <Fund>fundsList = res.setCacheable(true).list();
List<FundPOJO> funds = mapFunds(fundsList);
tx.commit();
return funds;
}
[code]
Yes it is a detached problem. Lets say I create a object called Bank with a many to many mapping to an acount, and account has a many to many mapping to a fund.

Then I want to update the bank object by adding  another account but maps to the same fund, that will cause the error.  
What I can do is map the account to the bank, and then in a seperate call to the repository, map the fund to the account, and that way it works.

Yes , have a seperate entity for each object you are saving. I would have PersonPOJO map to a PersonEntity, and save that enity in a personRepository which would have my hibernate or JPA functionality.
Also think of caching, if you are going to cashe in hibernate second level. It would be as an entity.
I am getting the following error


I know what is causing the problem, but not how to fix it.

i have the following manyToMany mapping

Bank <-> Account <-> Fund

I have a Bank BankId 123 that bank has Account accountId 1234 with fund fundId 12345
If I add to Bank  BankId 123  a new Account accountId 1235 but with with fund fundId 12345
It will fall over

It wont allow me to add an existing fund, from one account to another account, if both accouts are mapped to the same Bank.  I am using org.springframework.data.jpa.repository.JpaRepository; save() for my entity

The Entities are






Thanks for any help in a work around.
I trying to download eclipse. https://www.eclipse.org/downloads/packages. I Have tried 4 times, each time the installer just hangs, what happen to just a nice simple download zip and unzip. Now even the package is taking almost an hour.

anyone else with the same problems. almost tempted to try intellij, although they have horrific downloads, which was why i kept with eclipse.
1 year ago
I am running Ehcache as a Hibernate second session Does this logging of my second search say its working


Does this say its just adding it and hit just means its added
1 year ago
Hi ok what I needed to do was the following for my config class I added a link to pick up my Spring.xml @ImportResource("classpath:/spring.xml")

I think the reverse is happening, because I have set my


Its overwriting the FundRepositoryImpl in my XML.

Is there a way to say dontoverwrite the FundRepositoryImpl in my XML.