|
ColdPie posted:Reflection! And Generics! Just to double check what you're meaning, given any Vector<?> you want to retrieve the class of ? at runtime? Sorry to say but you can't. Java uses type erasure for generics which means at runtime all the type information is gone.
|
# ¿ Mar 18, 2008 02:04 |
|
|
# ¿ Apr 27, 2024 15:45 |
|
ColdPie posted:Lame. Then what's the point of Class.getTypeParameters()? It just gives you a nice representation of the classes generic declaration. i.e. code:
|
# ¿ Mar 18, 2008 03:53 |
|
TRex EaterofCars posted:I'm curious what that client's excuse for sticking with Java 1.3 is. Did they use some Sun internal API that got removed?
|
# ¿ Mar 22, 2008 16:46 |
|
FearIt posted:I'm typing 'objectsName.' in my IDE (eclipse) and when the list of methods comes up none of them are clone(). The object is a class I defined myself, would I need it to implement something for .clone() to work? Or alter my class in someway? clone() is protected in Object, you need to open it up yourself in the class you want to clone.
|
# ¿ Mar 25, 2008 03:25 |
|
Mill Town posted:Sounds cool, but I see it takes SQL commands as raw text. Is there a sanitize function available? I can't find one by searching the site or Google. Thanks!
|
# ¿ Aug 21, 2008 04:21 |
|
epswing posted:In an RDBMS, it's typical to normalize something like UserType (or PaymentMethod) into into its own table like 1=admin, 2=viewer (or 1=cash, 2=cheque, 3=creditcard), and other tables reference them by id. Such tables won't change, typically. In Java code, it makes sense to think of these as enums, so a Payment class would have a PaymentMethod field, where PaymentMethod is an enum: PaymentMethod.CASH, PaymentMethod.CHEQUE, etc. We do it that way, use a UserType to handle the mapping, you should be able to do it pretty generically and handle just about every type you'll encounter (they usually just pass a number id through to hibernate on persistence, the other parameters of the enum are just for pretty printing and stuff). You can then use the enum object itself in HQL/Criteria/setters/etc.
|
# ¿ Dec 8, 2008 03:44 |
|
epswing posted:I'm finding your reply somewhat vague. What do you mean by "that way"? Can you give an example? All the samples you posted use a UserType to control the marshalling between the enum and the database, the only real differences between them are personal preference. That's pretty much how everyone does it. The cleanest example is probably http://appfuse.org/display/APF/Java+5+Enums+Persistence+with+Hibernate and you can take it a bit further and put and interface over your enums so you don't have to always specify the identifierMethod or the valueOfMethod.
|
# ¿ Dec 9, 2008 00:01 |
|
8ender posted:Does anyone here have any experience with the various persistence APIs? I'm trying to decide which ones to evaluate right now and its a maze of wierdness when it comes to who owns what and which is a standard or not. The JPA is just the set of interfaces that live in the runtime and all the providers your listed implement them. I've only every used Hibernate, there isn't anything it doesn't do that I've needed. It just plops in and works. It's also got a pretty big userbase for reference material.
|
# ¿ Mar 17, 2009 13:42 |
|
|
# ¿ Apr 27, 2024 15:45 |
|
8ender posted:Sorry, I guess I meant the "Toplink Essentials/Hibernate mashup" that is bundled with the EJB 3.0 spec. How would you compare Hibernate to EclipseLink? In my case we have an existing data model and we'll be trying to match to our database. I've never used Eclipselink in a project before so I'm going on what I've read, Eclipselink is apparently better at it's second-level caching and probably has an out of the box cluster aware caching ability (Hibernate requires you to pick a caching provider first), and it's also quite awesome when running against the latest Oracle instances which I guess is to be expected. It's also got a bunch of stuff embedded in it that Hibernate doesn't have like JAXB support which I'm not too confident about because the two just don't fit together. You need seperate models to do both JPA and JAXB annotations as using a feature of one always ends up meaning you can't do something with the other. Personally for your situation I'd just go with Hibernate, annotate your domain model against the JPA as much as you can without straying into Hibernate's extensions and that way if Hibernate doesn't fit your needs substituting Eclipselink in won't be hard.
|
# ¿ Mar 17, 2009 22:33 |