Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [dali-dev] Re: schema for JPA connections

Hi Tom,

Some comments in-line.

Neil

Tom Mutdosch wrote:

Hi Neil,

I guess the main scenario that I am trying to address is a new user who wants to add some JPA data to their application. They see the JPA Generate Entities menu item and run that - they define their connection, they choose their schema and generate entities. Now they attempt to run their app but run into two problems:
1) no connection information is set up
2) the wrong schema is being used
However, the user definitively specified both of these things when they ran through the scenario. So it may be confusing why things aren't working. I'd like to see some assistance for the user in these cases.

I agree that this is a usability issue, and perhaps we need to look at making some changes to Dali to make it more usable out-of-the-box (without extensions). In the area of vendor properties, this would be a departure from our current design.

Regarding 1) Since the connection info is a property of a specific runtime implementation, it is expected that the platform provider is going to appropriately update the persistence.xml properties with this information as a part of their Dali extension.

Regarding 2) This depends on what has been configured by the specific platform, among other things.

I would think that the connection would generally be defined during project creation, not Entity Generation, but it might be a nice feature to set the connection for the project during Entity Generation if no connection is defined yet for the project.

Regarding the schema, what about when generating entities with a non-default schema, if there was an option to "Make this my default schema" or something to that affect. This would add the schema to your orm.xml (and possibly an option to add the schema directly to your entities via annotation). This would alleviate the problem. The option could even be off by default, so it would have to be deliberately enabled. What about something along these lines?

When designated, setting the non-default schema name in the orm.xml persistence-unit-defaults makes sense to me. Enter an enhancement for this and I will target it for 2.0. I'm not sure that the annotation based setting would be as useful, since generally you would only set schema in the annotations for the occasional table outside of the main schema (such as a sequence table for example).

As for assisting with the connection, I've brought this up several times on the list. I'm pretty sure that it's a function of the platform, but I'm not sure how to best handle this. That is, if the user selects the OpenJpa platform and defines a connection, can I hook in somewhere to allow the user to push this connection information to the persistence.xml (via the provider-specific properties, or a jta-datasource reference)?

Yes, this is how things are envisioned to work. You can obtain the connection information from our db plugin and insert the appropriate properties into the persistence.xml via our persistence unit model.

Ideally, I'd like some way to hook into the Generate Entities wizard where you select your connection and schema, to provide my own platform-specific options. Could something like this be set up? It may be possible to do now, by extending some of the existing Dali wizards, but that's usually not the preferred way to go. I was trying to handle this after the Generate Entities operation has run, but couldn't find a way to get the connection or schema that was used in that operation. It doesn't look like the selected connection gets set in project's JPA property page, so I couldn't rely on that property being set. Is this by design that the user has to explicitly go in and set this?

We haven't thought about integrating anything into the Generate Entities wizard. Currently we don't keep any of that information around as you describe. After some of the enhancements above are implemented, it would seem possible to obtain this information from the orm.xml and the project settings.


Thanks
Tom

dali-dev-request@xxxxxxxxxxx wrote:


the way things are going to work at runtime when setting your JDBC userName in the provider properties. This default is properly overridden in the orm.xml persistence-unit-defaults, or as specified by annotation, or as specified in the orm.xml for a given element. There are a LOT of places to set the schema, depending on the granularity that you need. This JPA meta data is the where schema information is stored.

Our validation has to take into account all of these possible schema settings to determine whether a database object can be resolved for a given Entity/Mapping. There is no master, all overriding, tool-only schema setting. We have too many schema settings to keep track of as it stands. ;) There is a possible argument for having this, but with so many existing schema settings and defaults, I worry that by removing confusion on the tooling side with a simple setting, you might complicate issues when you try to run your application and don't get the results that you expect.



As for Entity Generation, this does create a bit of an issue when generating from the non-default schema. I'll carry that conversation forward in the bug, but it probably needs some discussion to determine the best course of action.



Neil


_______________________________________________
dali-dev mailing list
dali-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dali-dev



Back to the top