Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Controlling column order when creating tables with ddl-generation
Controlling column order when creating tables with ddl-generation [message #388115] Mon, 25 May 2009 11:33 Go to next message
Dean Schulze is currently offline Dean Schulze
Messages: 24
Registered: July 2009
Junior Member
I'm using EclipseLink with the "eclipselink.ddl-generation" property set
to "create-tables". The order of the columns in the created tables seems
random. I want the columns in a particular order - the order in which the
fields appear in the Entity class definition.

My database is PostgresQL.

Is there a way to tell EclipseLink to create the columns in the order in
the Entity class definition or some other way to specify column order?

Thanks.
Re: Controlling column order when creating tables with ddl-generation [message #388423 is a reply to message #388115] Mon, 25 May 2009 14:01 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

There is a method on ClassDescriptor in EclipseLink,
setShouldOrderMappings(), if you set this to false, you might get the
order you are looking for.

Otherwise, you could use your own script to create your tables, the order
the columns are declared in should not really matter.

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: Controlling column order when creating tables with ddl-generation [message #735928 is a reply to message #388423] Thu, 13 October 2011 02:50 Go to previous messageGo to next message
Boyd Pang is currently offline Boyd Pang
Messages: 12
Registered: June 2011
Junior Member
Hello James,

In my application,I define an entity class and a class implements DescriptorCustomizer,


@Entity
@Table(name = "adapter")
@Customizer(OrderCustomizer.class)
public class AdapterRecord implements Comparable<AdapterRecord>, Serializable
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	private String name;
	
	private int serialNum;
	
	private boolean isRunnig;
	
	private String serverIp;

	@Temporal(TemporalType.TIMESTAMP)
	private Date startTime;
	
	private int test;
	private int test1;
	private int ptest;
	
	private String pIp;
	private String sIp;
	
	private int aTest;

......
}


public class OrderCustomizer implements DescriptorCustomizer
{
	@Override
	public void customize(ClassDescriptor descriptor)
	{
		descriptor.setShouldOrderMappings(false);

	}


}



I want the columns in a particular order - the order in which the
fields appear in the Entity class definition.

But when I run the application ,I got columns order :

index.php/fa/4248/0/

starttime,
id,
atest,
test1,
test,
name,
serverip,
isrunning,
serialnum,
pIp,
ptest,
sip

Could you give me some help ? Thanks a lot.

Boyd
  • Attachment: columns.JPG
    (Size: 51.96KB, Downloaded 362 times)

[Updated on: Thu, 13 October 2011 02:56]

Report message to a moderator

Re: Controlling column order when creating tables with ddl-generation [message #741962 is a reply to message #735928] Wed, 19 October 2011 23:49 Go to previous messageGo to next message
Boyd Pang is currently offline Boyd Pang
Messages: 12
Registered: June 2011
Junior Member
Can someone help me?

Thanks for any suggestion.

Boyd.

[Updated on: Wed, 19 October 2011 23:50]

Report message to a moderator

Re: Controlling column order when creating tables with ddl-generation [message #741966 is a reply to message #735928] Wed, 19 October 2011 23:49 Go to previous message
Boyd Pang is currently offline Boyd Pang
Messages: 12
Registered: June 2011
Junior Member
Can someone help me?

Thanks for any suggesion.

Boyd.
Previous Topic:Problem persisting TimestampTZ with JPA
Next Topic:Cached Ordered Lists have null inserted during 2nd update
Goto Forum:
  


Current Time: Thu Jul 24 04:28:19 EDT 2014

Powered by FUDForum. Page generated in 0.02023 seconds