[Hibernate] Selective SchemaExport
I have some tables in my hibernate mapping that I am in not control of. However, I like being able to automatically create and change (drop and recreate) my tables. It saves a ton of time. With the tables that I am not in control of (and have mappings to) I have run into a problem. In order for the mappings to compile appropriately (they are foreign keyed) I have to have the mappings for the tables that I am not in control on in the argument list for the schemaexport tool. However, I don’t want those particular tables generated. Is there a way to tell the schemaexport tool about those mappings but to tell it not to generate the ddl for particular mappings? LES
[Hibernate] Better validate on property and value ?
Hi! Should we not make a validate(Mapping) on property and value which throws appropiate exceptions (especially with a more precise message) the the current on in ClassPersister which just call's isValid() and assumes it has soemthing to do with number of columns Any reasons/arguments against having validate(Mapping) throws MappingException instead isValid(Mapping) that just return true/false ? (we could implement isValid(Mapping) in terms of validate(Mapping). /max --- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click ___ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel
RE: [Hibernate] Better validate on property and value ?
Title: RE: [Hibernate] Better validate on property and value ?
Whats wrong with doing:
public boolean isValid(Mapping mapping) {
try {
validate(mapping);
} catch (MappingException me) {
return false;
}
return true;
}
?
At least that way you get the added functionality of the validate method and still retain the old functionality...
Its an obvious solution, I know, but anything that gives flexibility and control without cluttering up things or breaking OO principles is probably a good thing I would think...
Perhaps a better approach would be to do something similar to Spring's Validator. At least that way gives you more control over identifying which fields were invalid (if you need that information):
public boolean isValid(Mapping mapping) {
Validator validator = new MappingValidator();
Errors errors = new Errors();
validator.validate(mapping, errors);
//Errors object encapsulates locale specific messages
//and a bunch of other stuff...
if (errors.isEmpty()) {
return true;
} else {
//do other stuff with error info, if needed
//...
return false;
}
}
(of course another approach is to have validate(mapping) return an Errors instance and check for null before processing...
Just thinking out loud...
Les
> -Original Message-
> From: Max Rydahl Andersen [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 30, 2003 5:18 PM
> To: hibernate-devel
> Subject: [Hibernate] Better validate on property and value ?
>
>
> Hi!
>
> Should we not make a validate(Mapping) on property and value which
> throws appropiate exceptions (especially with a more precise message)
> the the current on in ClassPersister which just call's isValid() and
> assumes it has soemthing to do with number of columns
>
> Any reasons/arguments against having validate(Mapping) throws
> MappingException instead isValid(Mapping) that just return
> true/false ?
> (we could implement isValid(Mapping) in terms of validate(Mapping).
>
> /max
>
>
> ---
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign
> up for IBM's Free Linux Tutorials. Learn everything from the
> bash shell to sys admin. Click now!
> http://ads.osdn.com/?ad_id=1278&alloc_id=3371> &op=click
>
> ___
>
> hibernate-devel mailing list [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel
>
Re: [Hibernate] Better validate on property and value ?
Les Hazlewood wrote:
Whats wrong with doing:
public boolean isValid(Mapping mapping) {
try {
validate(mapping);
} catch (MappingException me) {
return false;
}
return true;
}
?
> (we could implement isValid(Mapping) in terms of validate(Mapping).
That line was exactly that ;)
Your other suggestions is also valid, but does more than needed - we
just need to inform the user of
first error - Keeping it simple.
/max
> /max
>
>
> ---
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign
> up for IBM's Free Linux Tutorials. Learn everything from the
> bash shell to sys admin. Click now!
> http://ads.osdn.com/?ad_id=1278&alloc_id=3371
> &op=click
>
> ___
>
> hibernate-devel mailing list [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel
>
---
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
___
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel
