Skip to main content



      Home
Home » Eclipse Projects » Dali » Does Dali work with property access?
Does Dali work with property access? [message #544924] Tue, 06 July 2010 01:46 Go to next message
Eclipse UserFriend
I have a JPA2 project that uses Hibernate as the persistence provider. In some of my classes I am trying to mix property access and field access using the @Access annotation.

In these classes Dali does not seem to recognize the properties as persistent when I click on the property getter method -- only the fields.

Is this a known issue (with hibernate), or is something probably mis-configured somewhere?

[Updated on: Tue, 06 July 2010 02:19] by Moderator

Re: Does Dali work with property access? [message #545057 is a reply to message #544924] Tue, 06 July 2010 10:29 Go to previous messageGo to next message
Eclipse UserFriend
If you specify the access type on the Entity, Dali will handle mixed access type. This is a JPA spec requirement. Say you specify FIELD access on the entity, then on each getter that you want to map you have to specify PROPERTY. If there is a corresponding field for the property you will want to annotate it as @Transient.

Dali Generic platform defaults to FIELD if no access type is specified. The Hibernate platform should default to PROPERTY to match the Hibernate implementation, though I think this is something that is currently being fixed.

Please include an example that is not working for you if this does not help.

Karen
Re: Does Dali work with property access? [message #545185 is a reply to message #545057] Tue, 06 July 2010 22:02 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the response. I am very happy to hear this is supposed to work!

Karen Butzke wrote on Tue, 06 July 2010 10:29
Please include an example that is not working for you if this does not help.


For me, running Eclipse 3.5.2 with Hibernate 3.5.3-FINAL the following does not work:
@Entity
@Access(AccessType.FIELD)
Class Foo {

  @Id
  int id;

  @Column(name = "myfield")
  String myField;

  @Column(name = "myProp")
  @Access(AccessType.PROPERTY)
  public int getMyProp () {
    return 3;
  }

  public void setMyProp (int p) {
    // do nothing
  }
}


Clicking on the "getMyProp" method does nothing in Dali. Again, this could very possibly be a hibernate problem. I am in the process of filing a bug with Hibernate to let them know that the above class generates the wrong DDL (only 2 of the 3 columns are created -- the myProp column is not created).
Re: Does Dali work with property access? [message #545389 is a reply to message #545185] Wed, 07 July 2010 11:39 Go to previous messageGo to next message
Eclipse UserFriend
Ah, I wasn't thinking yesterday that you could be using a previous version of Eclipse. The mixed access type support was not available in the JPA 1.0 spec. Dali added JPA 2.0 support in Eclipse 3.6. The use case you have given works fine there.

It sounds like this is probably the issue with Hibernate as well, that the version you are using does not implement the JPA 2.0 spec.

Karen
Re: Does Dali work with property access? [message #545411 is a reply to message #545389] Wed, 07 July 2010 12:49 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the info -- my first good reason for upgrading to 3.6! Cool
Re: Does Dali work with property access? [message #619295 is a reply to message #544924] Tue, 06 July 2010 10:29 Go to previous messageGo to next message
Eclipse UserFriend
If you specify the access type on the Entity, Dali will handle mixed access type. This is a JPA spec requirement. Say you specify FIELD access on the entity, then on each getter that you want to map you have to specify PROPERTY. If there is a corresponding field for the property you will want to annotate it as @Transient.

Dali Generic platform defaults to FIELD if no access type is specified. The Hibernate platform should default to PROPERTY to match the Hibernate implementation, though I think this is something that is currently being fixed.

Please include an example that is not working for you if this does not help.

Karen
Re: Does Dali work with property access? [message #619299 is a reply to message #545057] Tue, 06 July 2010 22:02 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the response. I am very happy to hear this is supposed to work!

Karen Butzke wrote on Tue, 06 July 2010 10:29
> Please include an example that is not working for you if this does not help.


For me, running Eclipse 3.5.2 with Hibernate 3.5.3-FINAL the following does not work:

@Entity
@Access(AccessType.FIELD)
Class Foo {

@Id
int id;

@Column(name = "myfield")
String myField;

@Column(name = "myProp")
@Access(AccessType.PROPERTY)
public int getMyProp () {
return 3;
}

public void setMyProp (int p) {
// do nothing
}
}

Clicking on the "getMyProp" method does nothing in Dali. Again, this could very possibly be a hibernate problem. I am in the process of filing a bug with Hibernate to let them know that the above class generates the wrong DDL (only 2 of the 3 columns are created -- the myProp column is not created).
Re: Does Dali work with property access? [message #619301 is a reply to message #619299] Wed, 07 July 2010 11:39 Go to previous messageGo to next message
Eclipse UserFriend
Ah, I wasn't thinking yesterday that you could be using a previous version of Eclipse. The mixed access type support was not available in the JPA 1.0 spec. Dali added JPA 2.0 support in Eclipse 3.6. The use case you have given works fine there.

It sounds like this is probably the issue with Hibernate as well, that the version you are using does not implement the JPA 2.0 spec.

Karen
Re: Does Dali work with property access? [message #619302 is a reply to message #619301] Wed, 07 July 2010 12:49 Go to previous message
Eclipse UserFriend
Thanks for the info -- my first good reason for upgrading to 3.6! 8)
Previous Topic:Indigo feature planning - Refactoring participation
Next Topic:Not able to generate the JPA Manager Bean
Goto Forum:
  


Current Time: Sun Jul 06 09:25:09 EDT 2025

Powered by FUDForum. Page generated in 0.04892 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top