A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
OCA Java SE 8 Programmer I Study Guide 1Z0-808
this week in the
Object Relational Mapping
Finding entity column length using JPA annotations
Joined: Sep 15, 2007
Feb 05, 2011 12:12:37
I've been looking for a solution to this problem and have only found examples using mapping.
[Edit]Fat fingered something.
I need to format the output of a result set to certain column lengths based on the DDL declared length.
If for instance my entity named "USER" has:
@Column(name = "USER_ID", length = 10) private String userId;
I'd like to do something like:
String.format("%-*.*s", getColumnLength("USER", "userId"), getColumnLength("USER", "userId"), user.userId);
This is a simple example of how I'd like to do it and realize there's more elbow grease involved, but hopefully it makes sense.
Anyone done anything like this before?
[Edit] Forgot to mention I'm using Hibernate.
-- Nothing is impossible if ImPossible
Joined: Aug 08, 2011
Aug 08, 2011 10:53:35
Hi, I need the same and I have found a solution that retrieves the annotation from the class in a managed bean procedure. I can't retrieve some annotations from database, even I have to define in the class. I'm work with Netbeans 6.9.1.
I agree. Here's the link:
subject: Finding entity column length using JPA annotations
Automatically Persisting non existing entity in One To One mapping
hibernate mapping question
Edit primary key, if it's a foreign key
Serializable two times within a entity?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015