-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Annotations, OneToMany
PostPosted: Fri Nov 28, 2008 2:21 pm 
Newbie

Joined: Fri Nov 28, 2008 1:45 pm
Posts: 1
Hello,

Help me, i need to make a relantionship with 1:N

Phone.java has a FK (cli_id)


Code:
Client.java
[...]
   @OneToMany
        @JoinColumn(name="cli_id")
   private List<Phone> phone;
[...]



Code:
Phone.java
[...]
        @ManyToOne
        @JoinColumn(name="cli_id")
   private Client client;
[...]


Code:
[...]
Use.java

Cliente cli = new Cliente();
Phone tel = new Phone();
List<Phone> lis = null;

cli.setCli_name("help");
tel.setPho_num(12);
lis.add(tel);
cli.setCli_phone(lis);
dao.saveRecord(cli);

[...]


Code:
[...]
Error

DEBUG - AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(253) | Invoking BeanPostProcessors before instantiation of bean 'clientDAO'
DEBUG - CachedIntrospectionResults.<init>(148) | Getting BeanInfo for class [org.model.dao.ClientDAOImpl]
Exception in thread "main" java.lang.NullPointerException
   at teste.TesteCliente.main(Use.java:45)
DEBUG - CachedIntrospectionResults.<init>(164) | Caching PropertyDescriptors for class [org.model.dao.ClientDAOImpl]


[...]


; (

I trying to save a list of phones directly on client (set)

best regards, John


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.