This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 167419 - JPA @Embedded annotation flagged as error (only basic attributes allowed)
Summary: JPA @Embedded annotation flagged as error (only basic attributes allowed)
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Sergey Petrov
URL:
Keywords:
: 225343 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-06-21 09:23 UTC by catweasle
Modified: 2013-03-27 12:59 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
error message in 6.9b (19.67 KB, image/jpeg)
2010-04-29 10:13 UTC, catweasle
Details
entity with editor error (4.11 KB, application/octet-stream)
2010-04-29 10:17 UTC, catweasle
Details
copied class + dependencies (4.42 KB, application/x-zip-compressed)
2010-04-29 10:20 UTC, catweasle
Details
maven module (263.33 KB, application/x-zip-compressed)
2010-04-29 11:22 UTC, catweasle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description catweasle 2009-06-21 09:23:35 UTC
JPA @Embedded annotation is erraneously considered a basic type by the editor and flagged with an ERROR: basic
attributes can only be of the following types. (NB6.7RC3)
Code builds fine.
Comment 1 catweasle 2009-06-21 09:25:20 UTC
    @Embedded
    public Address getAddress() {
        return address;
    }
Comment 2 Sergey Petrov 2010-04-28 12:07:39 UTC
either fixed or need more details. 
just tried to create entity in 6.9:
@Entity
public class NewEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long id;

    private Customer cust;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Embedded
    public Customer getCust(){
        return cust;
    }

and embedded  have no errors regarding basic type, have only a warning about undefined relationship.
if the issue is still valid, please provide complete source if possible.
Comment 3 catweasle 2010-04-28 13:22:11 UTC
I can confirm that the bug is still present in latest official version 6.8.
Did not install 6.9 yet.
Comment 4 Sergey Petrov 2010-04-28 13:24:28 UTC
I don't remember any fixes in the area, can you provide more details?
Comment 5 catweasle 2010-04-28 17:57:45 UTC
(slowly) downloaded 6.9b: the issue is solved! 
thanks!
Comment 6 catweasle 2010-04-29 10:13:43 UTC
Created attachment 98262 [details]
error message in 6.9b
Comment 7 catweasle 2010-04-29 10:17:04 UTC
Created attachment 98263 [details]
entity with editor error
Comment 8 catweasle 2010-04-29 10:20:45 UTC
Created attachment 98264 [details]
copied class  + dependencies
Comment 9 catweasle 2010-04-29 10:34:46 UTC
Well, I was too fast (or NB6.9b is too slow).
It took about 10' before he rescanned everything and the error reappeared.

I copied over the offending class to a test package for isolated reproduction and... the error disappeared.
Another warning dissappeared in the editor in the copied class:
in the original Organization.java there's an editor warning "the project does not contain a persistence unit".
In the copied class the warning is not there.
This is a multimodule maven project.
Comment 10 Sergey Petrov 2010-04-29 10:56:00 UTC
Can you provide complete sample project?
I got this error on     @Embedded
    public Address getLocation() {
but only when Address  was simple class isn't annotated with @Embeddable, after annotation addition error gone away.
Comment 11 catweasle 2010-04-29 11:22:11 UTC
Created attachment 98267 [details]
maven module
Comment 12 Sergey Petrov 2010-04-29 11:40:07 UTC
tried to open the project, it complain about source level 1.3 and after change to 1.6 became corrupted, it may be an issue in maven projects support. may be the issue with projects created on windows and opened on linux.
will try on win a bit later.
Comment 13 catweasle 2010-04-29 11:44:20 UTC
I'm on vista/java 6 indeed
Comment 14 Sergey Petrov 2010-10-13 14:10:34 UTC
ok, tried it on windows with 6.9.1 and it show some dependencies is missed (not in local repository), also it's still 1.3 source level and attempt to correct source level make project corrupted, have you tried to open attached project?
Comment 15 catweasle 2011-08-03 16:11:27 UTC
I reproduced the bug on NB 7.0.1.
I think I now what the issue is:
The error is reported if the Embeddable class (Address) is NOT Serializable (which is valid code).
NetBeans will display a hint to make it Serializable.
If you make the embeddable Serializable the error in the embedding class disappears.
Netbeans should not give an error on embedding of non Serializable Embeddables.
Comment 16 svanimpe 2013-01-25 08:29:53 UTC
I also have this issue with 7.3 beta 2, and consider it a very annoying bug.
As catweasle said: the error goes away if you make the embeddable serialisable as well, but you shouldn't have to.
Comment 17 Sergey Petrov 2013-01-25 12:25:09 UTC
*** Bug 225343 has been marked as a duplicate of this bug. ***
Comment 18 martinandersson.com 2013-03-09 12:52:25 UTC
Can confirm it is an issue on Windows 8 x64 Professional, using Netbeans IDE 7.3, build 201302132200.
Comment 19 Sergey Petrov 2013-03-27 12:59:30 UTC
http://hg.netbeans.org/web-main/rev/8c584b8da6e4
Basic... validator should skip @Embedded now.