facebook

JPA Reverse Eng. to List vs Set collections

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #280493 Reply

    Ramin
    Member

    Hi,

    I use straight JPA (not Hibernate) in 6.0.1GA.
    The generated collections are created as something like this:

    private Set<T> myColl = new HashSet<T>(0);

    The accessor methods have similar signatures.

    Of course, Sets are NOT ordered thus, I’d like to have MyEclipse to generate the code as an ordered collection (e.g., ArrayList).

    Is this supported in the latest release? If not, do you have an ETA?
    Is it possible to use jpa.reveng.xml somehow?

    PS I’ve already read the comments at the following link:
    https://www.genuitec.com/forums/topic/overridding-collection-type-w-hibernate-backed-jpa-rev-eng/#post-277330

    #280544 Reply

    Riyad Kalla
    Member

    Ramin, unfortunately this isn’t easy to change. The thread you noted is the best we can provide right now but it is a known limitation that we want to correct and make user-adjustable soon. I don’t know if management will OK it for the 6.5 release or not, but I can push for it.

    #280560 Reply

    Ramin
    Member

    Hi Riyad,

    It may not be an easy change, but I’d like to know my options until the fix comes through. I see two options; I need you to please verify them for me before I invest a lot of time to compensate for the limitation.

    Here are my options and some quick questions around them:

    1. Change the template as described in the link below. Questions: has this worked for others?

    2.Modify the existing and newly reverse engineered code: the definitions and access methods.

    In either case, will the underlying implementation (TopLink) support ordered lists? That is, will the order be honored when I use orderby annotation or build my SQL with “order by”?

    The specs say collections are supported 😉
    Do I need to and can I upgrade to the latest version with no issues?

    Your comments are greatly appreciated.

    #280562 Reply

    Riyad Kalla
    Member

    Ramin,
    1. The modification provided is a *suggestion* on how to modify the Velocity template to have it generate the code with lists instead of sets. This is not tested, merely a suggested workaround for the time being if you want to dig into the templates.

    2. I would probably suggest this instead of messing with the templates. It’s more straight forward and yes JPA supports ordered results. You shouldn’t have any problems.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: JPA Reverse Eng. to List vs Set collections

You must be logged in to post in the forum log in